mermaid-ast 0.4.0 → 0.6.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/dist/class-diagram.d.ts +129 -0
- package/dist/class-diagram.d.ts.map +1 -0
- package/dist/class-diagram.js +341 -0
- package/dist/diagram-wrapper.d.ts +66 -0
- package/dist/diagram-wrapper.d.ts.map +1 -0
- package/dist/diagram-wrapper.js +59 -0
- package/dist/er-diagram.d.ts +214 -0
- package/dist/er-diagram.d.ts.map +1 -0
- package/dist/er-diagram.js +405 -0
- package/dist/flowchart-graph-ops.d.ts +58 -0
- package/dist/flowchart-graph-ops.d.ts.map +1 -0
- package/dist/flowchart-graph-ops.js +262 -0
- package/dist/flowchart-types.d.ts +58 -0
- package/dist/flowchart-types.d.ts.map +1 -0
- package/dist/flowchart-types.js +6 -0
- package/dist/flowchart.d.ts +304 -0
- package/dist/flowchart.d.ts.map +1 -0
- package/dist/flowchart.js +615 -0
- package/dist/gantt.d.ts +199 -0
- package/dist/gantt.d.ts.map +1 -0
- package/dist/gantt.js +452 -0
- package/dist/index.d.ts +28 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -4
- package/dist/journey.d.ts +154 -0
- package/dist/journey.d.ts.map +1 -0
- package/dist/journey.js +323 -0
- package/dist/mindmap.d.ts +142 -0
- package/dist/mindmap.d.ts.map +1 -0
- package/dist/mindmap.js +350 -0
- package/dist/parser/er-parser.d.ts +17 -0
- package/dist/parser/er-parser.d.ts.map +1 -0
- package/dist/parser/er-parser.js +127 -0
- package/dist/parser/flowchart-parser.d.ts.map +1 -1
- package/dist/parser/flowchart-parser.js +10 -2
- package/dist/parser/gantt-parser.d.ts +17 -0
- package/dist/parser/gantt-parser.d.ts.map +1 -0
- package/dist/parser/gantt-parser.js +190 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +51 -2
- package/dist/parser/journey-parser.d.ts +17 -0
- package/dist/parser/journey-parser.d.ts.map +1 -0
- package/dist/parser/journey-parser.js +107 -0
- package/dist/parser/mindmap-parser.d.ts +17 -0
- package/dist/parser/mindmap-parser.d.ts.map +1 -0
- package/dist/parser/mindmap-parser.js +204 -0
- package/dist/parser/quadrant-parser.d.ts +17 -0
- package/dist/parser/quadrant-parser.d.ts.map +1 -0
- package/dist/parser/quadrant-parser.js +102 -0
- package/dist/parser/sankey-parser.d.ts +17 -0
- package/dist/parser/sankey-parser.d.ts.map +1 -0
- package/dist/parser/sankey-parser.js +62 -0
- package/dist/parser/timeline-parser.d.ts +17 -0
- package/dist/parser/timeline-parser.d.ts.map +1 -0
- package/dist/parser/timeline-parser.js +105 -0
- package/dist/quadrant.d.ts +122 -0
- package/dist/quadrant.d.ts.map +1 -0
- package/dist/quadrant.js +260 -0
- package/dist/renderer/class-renderer.d.ts.map +1 -1
- package/dist/renderer/class-renderer.js +12 -2
- package/dist/renderer/er-renderer.d.ts +19 -0
- package/dist/renderer/er-renderer.d.ts.map +1 -0
- package/dist/renderer/er-renderer.js +131 -0
- package/dist/renderer/flowchart-renderer.d.ts.map +1 -1
- package/dist/renderer/flowchart-renderer.js +22 -18
- package/dist/renderer/gantt-renderer.d.ts +19 -0
- package/dist/renderer/gantt-renderer.d.ts.map +1 -0
- package/dist/renderer/gantt-renderer.js +118 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +11 -1
- package/dist/renderer/journey-renderer.d.ts +19 -0
- package/dist/renderer/journey-renderer.d.ts.map +1 -0
- package/dist/renderer/journey-renderer.js +40 -0
- package/dist/renderer/mindmap-renderer.d.ts +19 -0
- package/dist/renderer/mindmap-renderer.d.ts.map +1 -0
- package/dist/renderer/mindmap-renderer.js +98 -0
- package/dist/renderer/quadrant-renderer.d.ts +12 -0
- package/dist/renderer/quadrant-renderer.d.ts.map +1 -0
- package/dist/renderer/quadrant-renderer.js +75 -0
- package/dist/renderer/sankey-renderer.d.ts +12 -0
- package/dist/renderer/sankey-renderer.d.ts.map +1 -0
- package/dist/renderer/sankey-renderer.js +27 -0
- package/dist/renderer/sequence-renderer.d.ts.map +1 -1
- package/dist/renderer/sequence-renderer.js +3 -5
- package/dist/renderer/state-renderer.d.ts.map +1 -1
- package/dist/renderer/state-renderer.js +2 -6
- package/dist/renderer/timeline-renderer.d.ts +19 -0
- package/dist/renderer/timeline-renderer.d.ts.map +1 -0
- package/dist/renderer/timeline-renderer.js +37 -0
- package/dist/sankey.d.ts +120 -0
- package/dist/sankey.d.ts.map +1 -0
- package/dist/sankey.js +217 -0
- package/dist/sequence.d.ts +134 -0
- package/dist/sequence.d.ts.map +1 -0
- package/dist/sequence.js +457 -0
- package/dist/state-diagram.d.ts +117 -0
- package/dist/state-diagram.d.ts.map +1 -0
- package/dist/state-diagram.js +331 -0
- package/dist/timeline.d.ts +154 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +340 -0
- package/dist/types/er.d.ts +105 -0
- package/dist/types/er.d.ts.map +1 -0
- package/dist/types/er.js +19 -0
- package/dist/types/gantt.d.ts +101 -0
- package/dist/types/gantt.d.ts.map +1 -0
- package/dist/types/gantt.js +18 -0
- package/dist/types/index.d.ts +50 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +56 -0
- package/dist/types/journey.d.ts +44 -0
- package/dist/types/journey.d.ts.map +1 -0
- package/dist/types/journey.js +14 -0
- package/dist/types/mindmap.d.ts +45 -0
- package/dist/types/mindmap.d.ts.map +1 -0
- package/dist/types/mindmap.js +13 -0
- package/dist/types/quadrant.d.ts +66 -0
- package/dist/types/quadrant.d.ts.map +1 -0
- package/dist/types/quadrant.js +15 -0
- package/dist/types/sankey.d.ts +40 -0
- package/dist/types/sankey.d.ts.map +1 -0
- package/dist/types/sankey.js +15 -0
- package/dist/types/timeline.d.ts +49 -0
- package/dist/types/timeline.d.ts.map +1 -0
- package/dist/types/timeline.js +14 -0
- package/dist/vendored/grammars/block.jison +290 -0
- package/dist/vendored/grammars/c4.jison +322 -0
- package/dist/vendored/grammars/er.jison +294 -0
- package/dist/vendored/grammars/gantt.jison +188 -0
- package/dist/vendored/grammars/journey.jison +69 -0
- package/dist/vendored/grammars/kanban.jison +166 -0
- package/dist/vendored/grammars/mindmap.jison +127 -0
- package/dist/vendored/grammars/quadrant.jison +187 -0
- package/dist/vendored/grammars/requirement.jison +267 -0
- package/dist/vendored/grammars/sankey.jison +67 -0
- package/dist/vendored/grammars/timeline.jison +79 -0
- package/dist/vendored/grammars/xychart.jison +172 -0
- package/dist/vendored/parsers/block.js +897 -0
- package/dist/vendored/parsers/c4.js +915 -0
- package/dist/vendored/parsers/class.js +369 -329
- package/dist/vendored/parsers/er.js +931 -0
- package/dist/vendored/parsers/flowchart.js +369 -329
- package/dist/vendored/parsers/gantt.js +802 -0
- package/dist/vendored/parsers/journey.js +655 -0
- package/dist/vendored/parsers/kanban.js +745 -0
- package/dist/vendored/parsers/mindmap.js +703 -0
- package/dist/vendored/parsers/quadrant.js +782 -0
- package/dist/vendored/parsers/requirement.js +871 -0
- package/dist/vendored/parsers/sankey.js +616 -0
- package/dist/vendored/parsers/sequence.js +369 -329
- package/dist/vendored/parsers/state.js +369 -329
- package/dist/vendored/parsers/timeline.js +656 -0
- package/dist/vendored/parsers/xychart.js +763 -0
- package/dist/vendored/sync-info.json +62 -2
- package/package.json +3 -6
- package/LICENSE +0 -21
- package/README.md +0 -542
- package/dist/builder/class-builder.d.ts +0 -148
- package/dist/builder/class-builder.d.ts.map +0 -1
- package/dist/builder/class-builder.js +0 -318
- package/dist/builder/flowchart-builder.d.ts +0 -123
- package/dist/builder/flowchart-builder.d.ts.map +0 -1
- package/dist/builder/flowchart-builder.js +0 -257
- package/dist/builder/index.d.ts +0 -10
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/index.js +0 -9
- package/dist/builder/sequence-builder.d.ts +0 -174
- package/dist/builder/sequence-builder.d.ts.map +0 -1
- package/dist/builder/sequence-builder.js +0 -443
- package/dist/builder/state-builder.d.ts +0 -156
- package/dist/builder/state-builder.d.ts.map +0 -1
- package/dist/builder/state-builder.js +0 -314
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class Diagram Wrapper Class
|
|
3
|
+
*
|
|
4
|
+
* A unified API for building, mutating, and querying class diagrams.
|
|
5
|
+
* Provides a fluent interface that wraps the ClassDiagramAST.
|
|
6
|
+
*/
|
|
7
|
+
import { DiagramWrapper } from './diagram-wrapper.js';
|
|
8
|
+
import type { ClassDefinition, ClassDiagramAST, ClassDirection, ClassMember, ClassRelation, LineType, RelationType } from './types/class.js';
|
|
9
|
+
import type { RenderOptions } from './types/render-options.js';
|
|
10
|
+
/** Options for adding a class */
|
|
11
|
+
export interface AddClassOptions {
|
|
12
|
+
label?: string;
|
|
13
|
+
annotation?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Options for adding a member */
|
|
16
|
+
export interface AddMemberOptions {
|
|
17
|
+
visibility?: '+' | '-' | '#' | '~';
|
|
18
|
+
type?: 'method' | 'attribute';
|
|
19
|
+
}
|
|
20
|
+
/** Options for adding a relation */
|
|
21
|
+
export interface AddRelationOptions {
|
|
22
|
+
label?: string;
|
|
23
|
+
labelFrom?: string;
|
|
24
|
+
labelTo?: string;
|
|
25
|
+
lineType?: LineType;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A fluent wrapper for ClassDiagramAST that supports building, mutating, and querying.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ClassDiagram extends DiagramWrapper<ClassDiagramAST> {
|
|
31
|
+
private constructor();
|
|
32
|
+
/** Create a new empty class diagram */
|
|
33
|
+
static create(direction?: ClassDirection): ClassDiagram;
|
|
34
|
+
/** Create from an existing AST */
|
|
35
|
+
static from(ast: ClassDiagramAST): ClassDiagram;
|
|
36
|
+
/** Parse Mermaid syntax into a ClassDiagram */
|
|
37
|
+
static parse(input: string): ClassDiagram;
|
|
38
|
+
render(options?: RenderOptions): string;
|
|
39
|
+
clone(): ClassDiagram;
|
|
40
|
+
get direction(): ClassDirection;
|
|
41
|
+
get classCount(): number;
|
|
42
|
+
get relationCount(): number;
|
|
43
|
+
get classes(): Map<string, {
|
|
44
|
+
id: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
memberCount: number;
|
|
47
|
+
}>;
|
|
48
|
+
setDirection(direction: ClassDirection): this;
|
|
49
|
+
/** Add a class */
|
|
50
|
+
addClass(id: string, options?: AddClassOptions): this;
|
|
51
|
+
/** Remove a class and optionally its relations */
|
|
52
|
+
removeClass(id: string, options?: {
|
|
53
|
+
removeRelations?: boolean;
|
|
54
|
+
}): this;
|
|
55
|
+
/** Rename a class */
|
|
56
|
+
renameClass(id: string, newId: string): this;
|
|
57
|
+
/** Get a class by ID */
|
|
58
|
+
getClass(id: string): ClassDefinition | undefined;
|
|
59
|
+
/** Check if class exists */
|
|
60
|
+
hasClass(id: string): boolean;
|
|
61
|
+
/** Set class label */
|
|
62
|
+
setClassLabel(id: string, label: string): this;
|
|
63
|
+
/** Add annotation to class */
|
|
64
|
+
addAnnotation(id: string, annotation: string): this;
|
|
65
|
+
/** Remove annotation from class */
|
|
66
|
+
removeAnnotation(id: string, annotation: string): this;
|
|
67
|
+
/** Add a member (attribute or method) to a class */
|
|
68
|
+
addMember(classId: string, text: string, options?: AddMemberOptions): this;
|
|
69
|
+
/** Add an attribute to a class */
|
|
70
|
+
addAttribute(classId: string, text: string, visibility?: '+' | '-' | '#' | '~'): this;
|
|
71
|
+
/** Add a method to a class */
|
|
72
|
+
addMethod(classId: string, text: string, visibility?: '+' | '-' | '#' | '~'): this;
|
|
73
|
+
/** Get members of a class */
|
|
74
|
+
getMembers(classId: string): ClassMember[];
|
|
75
|
+
/** Remove a member from a class */
|
|
76
|
+
removeMember(classId: string, text: string): this;
|
|
77
|
+
/** Add a relation between classes */
|
|
78
|
+
addRelation(from: string, to: string, relationType: RelationType, options?: AddRelationOptions): this;
|
|
79
|
+
/** Add inheritance relation (A extends B) */
|
|
80
|
+
addInheritance(child: string, parent: string, options?: AddRelationOptions): this;
|
|
81
|
+
/** Add composition relation */
|
|
82
|
+
addComposition(whole: string, part: string, options?: AddRelationOptions): this;
|
|
83
|
+
/** Add aggregation relation */
|
|
84
|
+
addAggregation(whole: string, part: string, options?: AddRelationOptions): this;
|
|
85
|
+
/** Add dependency relation */
|
|
86
|
+
addDependency(from: string, to: string, options?: AddRelationOptions): this;
|
|
87
|
+
/** Add association (simple line) */
|
|
88
|
+
addAssociation(from: string, to: string, options?: AddRelationOptions): this;
|
|
89
|
+
/** Get all relations */
|
|
90
|
+
getRelations(): ClassRelation[];
|
|
91
|
+
/** Get relations for a class */
|
|
92
|
+
getRelationsFor(classId: string): ClassRelation[];
|
|
93
|
+
/** Remove a relation */
|
|
94
|
+
removeRelation(from: string, to: string): this;
|
|
95
|
+
/** Add a namespace */
|
|
96
|
+
addNamespace(name: string, classIds?: string[]): this;
|
|
97
|
+
/** Add class to namespace */
|
|
98
|
+
addToNamespace(namespace: string, classId: string): this;
|
|
99
|
+
/** Remove class from namespace */
|
|
100
|
+
removeFromNamespace(namespace: string, classId: string): this;
|
|
101
|
+
/** Get namespace for a class */
|
|
102
|
+
getNamespaceFor(classId: string): string | undefined;
|
|
103
|
+
/** Add a note */
|
|
104
|
+
addNote(text: string, forClass?: string): this;
|
|
105
|
+
/** Get all notes */
|
|
106
|
+
getNotes(): Array<{
|
|
107
|
+
text: string;
|
|
108
|
+
forClass?: string;
|
|
109
|
+
}>;
|
|
110
|
+
/** Define a class style */
|
|
111
|
+
defineStyle(name: string, styles: string[]): this;
|
|
112
|
+
/** Apply style to a class */
|
|
113
|
+
applyStyle(classId: string, styleName: string): this;
|
|
114
|
+
/** Find classes by criteria */
|
|
115
|
+
findClasses(query: {
|
|
116
|
+
hasAnnotation?: string;
|
|
117
|
+
hasStyle?: string;
|
|
118
|
+
inNamespace?: string;
|
|
119
|
+
}): ClassDefinition[];
|
|
120
|
+
/** Get all subclasses of a class (direct inheritance) */
|
|
121
|
+
getSubclasses(classId: string): string[];
|
|
122
|
+
/** Get parent class (direct inheritance) */
|
|
123
|
+
getParentClass(classId: string): string | undefined;
|
|
124
|
+
/** Get all ancestors (transitive inheritance) */
|
|
125
|
+
getAncestors(classId: string): string[];
|
|
126
|
+
/** Get all descendants (transitive inheritance) */
|
|
127
|
+
getDescendants(classId: string): string[];
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=class-diagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-diagram.d.ts","sourceRoot":"","sources":["../src/class-diagram.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,iCAAiC;AACjC,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kCAAkC;AAClC,MAAM,WAAW,gBAAgB;IAC/B,UAAU,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACnC,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC/B;AAED,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,cAAc,CAAC,eAAe,CAAC;IAC/D,OAAO;IAMP,uCAAuC;IACvC,MAA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CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,eAAe,EAAE;IAcrB,yDAAyD;IACzD,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAMxC,4CAA4C;IAC5C,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOnD,iDAAiD;IACjD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAUvC,mDAAmD;IACnD,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;CAU1C"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class Diagram Wrapper Class
|
|
3
|
+
*
|
|
4
|
+
* A unified API for building, mutating, and querying class diagrams.
|
|
5
|
+
* Provides a fluent interface that wraps the ClassDiagramAST.
|
|
6
|
+
*/
|
|
7
|
+
import { DiagramWrapper } from './diagram-wrapper.js';
|
|
8
|
+
import { parseClassDiagram } from './parser/class-parser.js';
|
|
9
|
+
import { renderClassDiagram } from './renderer/class-renderer.js';
|
|
10
|
+
import { createClassDiagramAST } from './types/class.js';
|
|
11
|
+
/**
|
|
12
|
+
* A fluent wrapper for ClassDiagramAST that supports building, mutating, and querying.
|
|
13
|
+
*/
|
|
14
|
+
export class ClassDiagram extends DiagramWrapper {
|
|
15
|
+
constructor(ast) {
|
|
16
|
+
super(ast);
|
|
17
|
+
}
|
|
18
|
+
// ============ Factory Methods ============
|
|
19
|
+
/** Create a new empty class diagram */
|
|
20
|
+
static create(direction) {
|
|
21
|
+
const ast = createClassDiagramAST();
|
|
22
|
+
if (direction)
|
|
23
|
+
ast.direction = direction;
|
|
24
|
+
return new ClassDiagram(ast);
|
|
25
|
+
}
|
|
26
|
+
/** Create from an existing AST */
|
|
27
|
+
static from(ast) {
|
|
28
|
+
return new ClassDiagram(structuredClone(ast));
|
|
29
|
+
}
|
|
30
|
+
/** Parse Mermaid syntax into a ClassDiagram */
|
|
31
|
+
static parse(input) {
|
|
32
|
+
return new ClassDiagram(parseClassDiagram(input));
|
|
33
|
+
}
|
|
34
|
+
// ============ Core Methods ============
|
|
35
|
+
render(options) {
|
|
36
|
+
return renderClassDiagram(this.ast, options);
|
|
37
|
+
}
|
|
38
|
+
clone() {
|
|
39
|
+
return new ClassDiagram(structuredClone(this.ast));
|
|
40
|
+
}
|
|
41
|
+
// ============ Properties ============
|
|
42
|
+
get direction() {
|
|
43
|
+
return this.ast.direction;
|
|
44
|
+
}
|
|
45
|
+
get classCount() {
|
|
46
|
+
return this.ast.classes.size;
|
|
47
|
+
}
|
|
48
|
+
get relationCount() {
|
|
49
|
+
return this.ast.relations.length;
|
|
50
|
+
}
|
|
51
|
+
get classes() {
|
|
52
|
+
return new Map(Array.from(this.ast.classes.entries()).map(([id, cls]) => [
|
|
53
|
+
id,
|
|
54
|
+
{ id: cls.id, label: cls.label, memberCount: cls.members.length },
|
|
55
|
+
]));
|
|
56
|
+
}
|
|
57
|
+
// ============ Direction Operations ============
|
|
58
|
+
setDirection(direction) {
|
|
59
|
+
this.ast.direction = direction;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
// ============ Class Operations ============
|
|
63
|
+
/** Add a class */
|
|
64
|
+
addClass(id, options) {
|
|
65
|
+
const cls = {
|
|
66
|
+
id,
|
|
67
|
+
label: options?.label,
|
|
68
|
+
members: [],
|
|
69
|
+
annotations: options?.annotation ? [options.annotation] : [],
|
|
70
|
+
cssClasses: [],
|
|
71
|
+
styles: [],
|
|
72
|
+
};
|
|
73
|
+
this.ast.classes.set(id, cls);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/** Remove a class and optionally its relations */
|
|
77
|
+
removeClass(id, options) {
|
|
78
|
+
this.ast.classes.delete(id);
|
|
79
|
+
if (options?.removeRelations) {
|
|
80
|
+
this.ast.relations = this.ast.relations.filter((r) => r.id1 !== id && r.id2 !== id);
|
|
81
|
+
}
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/** Rename a class */
|
|
85
|
+
renameClass(id, newId) {
|
|
86
|
+
const cls = this.ast.classes.get(id);
|
|
87
|
+
if (cls) {
|
|
88
|
+
cls.id = newId;
|
|
89
|
+
this.ast.classes.delete(id);
|
|
90
|
+
this.ast.classes.set(newId, cls);
|
|
91
|
+
// Update relations
|
|
92
|
+
for (const rel of this.ast.relations) {
|
|
93
|
+
if (rel.id1 === id)
|
|
94
|
+
rel.id1 = newId;
|
|
95
|
+
if (rel.id2 === id)
|
|
96
|
+
rel.id2 = newId;
|
|
97
|
+
}
|
|
98
|
+
// Update namespaces
|
|
99
|
+
for (const ns of this.ast.namespaces.values()) {
|
|
100
|
+
const idx = ns.classes.indexOf(id);
|
|
101
|
+
if (idx >= 0)
|
|
102
|
+
ns.classes[idx] = newId;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
/** Get a class by ID */
|
|
108
|
+
getClass(id) {
|
|
109
|
+
return this.ast.classes.get(id);
|
|
110
|
+
}
|
|
111
|
+
/** Check if class exists */
|
|
112
|
+
hasClass(id) {
|
|
113
|
+
return this.ast.classes.has(id);
|
|
114
|
+
}
|
|
115
|
+
/** Set class label */
|
|
116
|
+
setClassLabel(id, label) {
|
|
117
|
+
const cls = this.ast.classes.get(id);
|
|
118
|
+
if (cls)
|
|
119
|
+
cls.label = label;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
/** Add annotation to class */
|
|
123
|
+
addAnnotation(id, annotation) {
|
|
124
|
+
const cls = this.ast.classes.get(id);
|
|
125
|
+
if (cls && !cls.annotations.includes(annotation)) {
|
|
126
|
+
cls.annotations.push(annotation);
|
|
127
|
+
}
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/** Remove annotation from class */
|
|
131
|
+
removeAnnotation(id, annotation) {
|
|
132
|
+
const cls = this.ast.classes.get(id);
|
|
133
|
+
if (cls) {
|
|
134
|
+
cls.annotations = cls.annotations.filter((a) => a !== annotation);
|
|
135
|
+
}
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
// ============ Member Operations ============
|
|
139
|
+
/** Add a member (attribute or method) to a class */
|
|
140
|
+
addMember(classId, text, options) {
|
|
141
|
+
const cls = this.ast.classes.get(classId);
|
|
142
|
+
if (!cls) {
|
|
143
|
+
this.addClass(classId);
|
|
144
|
+
return this.addMember(classId, text, options);
|
|
145
|
+
}
|
|
146
|
+
const member = {
|
|
147
|
+
text,
|
|
148
|
+
visibility: options?.visibility,
|
|
149
|
+
type: options?.type,
|
|
150
|
+
};
|
|
151
|
+
cls.members.push(member);
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
/** Add an attribute to a class */
|
|
155
|
+
addAttribute(classId, text, visibility) {
|
|
156
|
+
return this.addMember(classId, text, { visibility, type: 'attribute' });
|
|
157
|
+
}
|
|
158
|
+
/** Add a method to a class */
|
|
159
|
+
addMethod(classId, text, visibility) {
|
|
160
|
+
return this.addMember(classId, text, { visibility, type: 'method' });
|
|
161
|
+
}
|
|
162
|
+
/** Get members of a class */
|
|
163
|
+
getMembers(classId) {
|
|
164
|
+
return this.ast.classes.get(classId)?.members ?? [];
|
|
165
|
+
}
|
|
166
|
+
/** Remove a member from a class */
|
|
167
|
+
removeMember(classId, text) {
|
|
168
|
+
const cls = this.ast.classes.get(classId);
|
|
169
|
+
if (cls) {
|
|
170
|
+
cls.members = cls.members.filter((m) => m.text !== text);
|
|
171
|
+
}
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
// ============ Relation Operations ============
|
|
175
|
+
/** Add a relation between classes */
|
|
176
|
+
addRelation(from, to, relationType, options) {
|
|
177
|
+
// Auto-create classes if they don't exist
|
|
178
|
+
if (!this.ast.classes.has(from))
|
|
179
|
+
this.addClass(from);
|
|
180
|
+
if (!this.ast.classes.has(to))
|
|
181
|
+
this.addClass(to);
|
|
182
|
+
const relation = {
|
|
183
|
+
id1: from,
|
|
184
|
+
id2: to,
|
|
185
|
+
relation: {
|
|
186
|
+
type1: relationType,
|
|
187
|
+
type2: 'none',
|
|
188
|
+
lineType: options?.lineType ?? 'solid',
|
|
189
|
+
},
|
|
190
|
+
title: options?.label,
|
|
191
|
+
relationTitle1: options?.labelFrom,
|
|
192
|
+
relationTitle2: options?.labelTo,
|
|
193
|
+
};
|
|
194
|
+
this.ast.relations.push(relation);
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
/** Add inheritance relation (A extends B) */
|
|
198
|
+
addInheritance(child, parent, options) {
|
|
199
|
+
return this.addRelation(parent, child, 'extension', options);
|
|
200
|
+
}
|
|
201
|
+
/** Add composition relation */
|
|
202
|
+
addComposition(whole, part, options) {
|
|
203
|
+
return this.addRelation(whole, part, 'composition', options);
|
|
204
|
+
}
|
|
205
|
+
/** Add aggregation relation */
|
|
206
|
+
addAggregation(whole, part, options) {
|
|
207
|
+
return this.addRelation(whole, part, 'aggregation', options);
|
|
208
|
+
}
|
|
209
|
+
/** Add dependency relation */
|
|
210
|
+
addDependency(from, to, options) {
|
|
211
|
+
return this.addRelation(from, to, 'dependency', options);
|
|
212
|
+
}
|
|
213
|
+
/** Add association (simple line) */
|
|
214
|
+
addAssociation(from, to, options) {
|
|
215
|
+
return this.addRelation(from, to, 'none', options);
|
|
216
|
+
}
|
|
217
|
+
/** Get all relations */
|
|
218
|
+
getRelations() {
|
|
219
|
+
return this.ast.relations;
|
|
220
|
+
}
|
|
221
|
+
/** Get relations for a class */
|
|
222
|
+
getRelationsFor(classId) {
|
|
223
|
+
return this.ast.relations.filter((r) => r.id1 === classId || r.id2 === classId);
|
|
224
|
+
}
|
|
225
|
+
/** Remove a relation */
|
|
226
|
+
removeRelation(from, to) {
|
|
227
|
+
this.ast.relations = this.ast.relations.filter((r) => !(r.id1 === from && r.id2 === to) && !(r.id1 === to && r.id2 === from));
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
// ============ Namespace Operations ============
|
|
231
|
+
/** Add a namespace */
|
|
232
|
+
addNamespace(name, classIds) {
|
|
233
|
+
this.ast.namespaces.set(name, {
|
|
234
|
+
name,
|
|
235
|
+
classes: classIds ?? [],
|
|
236
|
+
});
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
/** Add class to namespace */
|
|
240
|
+
addToNamespace(namespace, classId) {
|
|
241
|
+
let ns = this.ast.namespaces.get(namespace);
|
|
242
|
+
if (!ns) {
|
|
243
|
+
this.addNamespace(namespace);
|
|
244
|
+
ns = this.ast.namespaces.get(namespace);
|
|
245
|
+
}
|
|
246
|
+
if (!ns.classes.includes(classId)) {
|
|
247
|
+
ns.classes.push(classId);
|
|
248
|
+
}
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
/** Remove class from namespace */
|
|
252
|
+
removeFromNamespace(namespace, classId) {
|
|
253
|
+
const ns = this.ast.namespaces.get(namespace);
|
|
254
|
+
if (ns) {
|
|
255
|
+
ns.classes = ns.classes.filter((c) => c !== classId);
|
|
256
|
+
}
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
/** Get namespace for a class */
|
|
260
|
+
getNamespaceFor(classId) {
|
|
261
|
+
for (const [name, ns] of this.ast.namespaces) {
|
|
262
|
+
if (ns.classes.includes(classId))
|
|
263
|
+
return name;
|
|
264
|
+
}
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
// ============ Note Operations ============
|
|
268
|
+
/** Add a note */
|
|
269
|
+
addNote(text, forClass) {
|
|
270
|
+
this.ast.notes.push({ text, forClass });
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
273
|
+
/** Get all notes */
|
|
274
|
+
getNotes() {
|
|
275
|
+
return this.ast.notes;
|
|
276
|
+
}
|
|
277
|
+
// ============ Style Operations ============
|
|
278
|
+
/** Define a class style */
|
|
279
|
+
defineStyle(name, styles) {
|
|
280
|
+
this.ast.classDefs.set(name, { name, styles });
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
/** Apply style to a class */
|
|
284
|
+
applyStyle(classId, styleName) {
|
|
285
|
+
const cls = this.ast.classes.get(classId);
|
|
286
|
+
if (cls && !cls.cssClasses.includes(styleName)) {
|
|
287
|
+
cls.cssClasses.push(styleName);
|
|
288
|
+
}
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
// ============ Query Operations ============
|
|
292
|
+
/** Find classes by criteria */
|
|
293
|
+
findClasses(query) {
|
|
294
|
+
const results = [];
|
|
295
|
+
for (const cls of this.ast.classes.values()) {
|
|
296
|
+
if (query.hasAnnotation && !cls.annotations.includes(query.hasAnnotation))
|
|
297
|
+
continue;
|
|
298
|
+
if (query.hasStyle && !cls.cssClasses.includes(query.hasStyle))
|
|
299
|
+
continue;
|
|
300
|
+
if (query.inNamespace) {
|
|
301
|
+
const ns = this.ast.namespaces.get(query.inNamespace);
|
|
302
|
+
if (!ns || !ns.classes.includes(cls.id))
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
results.push(cls);
|
|
306
|
+
}
|
|
307
|
+
return results;
|
|
308
|
+
}
|
|
309
|
+
/** Get all subclasses of a class (direct inheritance) */
|
|
310
|
+
getSubclasses(classId) {
|
|
311
|
+
return this.ast.relations
|
|
312
|
+
.filter((r) => r.id1 === classId && r.relation.type1 === 'extension')
|
|
313
|
+
.map((r) => r.id2);
|
|
314
|
+
}
|
|
315
|
+
/** Get parent class (direct inheritance) */
|
|
316
|
+
getParentClass(classId) {
|
|
317
|
+
const rel = this.ast.relations.find((r) => r.id2 === classId && r.relation.type1 === 'extension');
|
|
318
|
+
return rel?.id1;
|
|
319
|
+
}
|
|
320
|
+
/** Get all ancestors (transitive inheritance) */
|
|
321
|
+
getAncestors(classId) {
|
|
322
|
+
const ancestors = [];
|
|
323
|
+
let current = this.getParentClass(classId);
|
|
324
|
+
while (current) {
|
|
325
|
+
ancestors.push(current);
|
|
326
|
+
current = this.getParentClass(current);
|
|
327
|
+
}
|
|
328
|
+
return ancestors;
|
|
329
|
+
}
|
|
330
|
+
/** Get all descendants (transitive inheritance) */
|
|
331
|
+
getDescendants(classId) {
|
|
332
|
+
const descendants = [];
|
|
333
|
+
const queue = this.getSubclasses(classId);
|
|
334
|
+
while (queue.length > 0) {
|
|
335
|
+
const child = queue.shift();
|
|
336
|
+
descendants.push(child);
|
|
337
|
+
queue.push(...this.getSubclasses(child));
|
|
338
|
+
}
|
|
339
|
+
return descendants;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagramWrapper Base Class
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class for diagram wrapper classes.
|
|
5
|
+
* Provides common functionality for building, mutating, and querying diagrams.
|
|
6
|
+
*
|
|
7
|
+
* Each diagram type (Flowchart, Sequence, Class, etc.) extends this base class
|
|
8
|
+
* and implements diagram-specific operations.
|
|
9
|
+
*/
|
|
10
|
+
import type { RenderOptions } from './types/render-options.js';
|
|
11
|
+
/**
|
|
12
|
+
* Base interface for all diagram ASTs
|
|
13
|
+
*/
|
|
14
|
+
export interface BaseDiagramAST {
|
|
15
|
+
type: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
accDescription?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Abstract base class for diagram wrappers.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam T - The specific AST type this wrapper manages
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class DiagramWrapper<T extends BaseDiagramAST> {
|
|
25
|
+
protected ast: T;
|
|
26
|
+
protected constructor(ast: T);
|
|
27
|
+
/**
|
|
28
|
+
* Render the diagram to Mermaid syntax
|
|
29
|
+
* @param options - Render options
|
|
30
|
+
*/
|
|
31
|
+
abstract render(options?: RenderOptions): string;
|
|
32
|
+
/**
|
|
33
|
+
* Create a deep clone of this diagram.
|
|
34
|
+
* Note: Returns the concrete type, not `this`, to avoid TypeScript polymorphic this issues.
|
|
35
|
+
*/
|
|
36
|
+
abstract clone(): DiagramWrapper<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the underlying AST
|
|
39
|
+
*/
|
|
40
|
+
toAST(): T;
|
|
41
|
+
/**
|
|
42
|
+
* Get the diagram type
|
|
43
|
+
*/
|
|
44
|
+
get type(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Get the diagram title
|
|
47
|
+
*/
|
|
48
|
+
get title(): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Set the diagram title
|
|
51
|
+
*/
|
|
52
|
+
set title(value: string | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Get the accessibility description
|
|
55
|
+
*/
|
|
56
|
+
get accDescription(): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Set the accessibility description
|
|
59
|
+
*/
|
|
60
|
+
set accDescription(value: string | undefined);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Helper type for extracting the AST type from a DiagramWrapper subclass
|
|
64
|
+
*/
|
|
65
|
+
export type ASTOf<W extends DiagramWrapper<any>> = W extends DiagramWrapper<infer T> ? T : never;
|
|
66
|
+
//# sourceMappingURL=diagram-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram-wrapper.d.ts","sourceRoot":"","sources":["../src/diagram-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,8BAAsB,cAAc,CAAC,CAAC,SAAS,cAAc;IAC3D,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;IAEjB,SAAS,aAAa,GAAG,EAAE,CAAC;IAQ5B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM;IAEhD;;;OAGG;IACH,QAAQ,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC;IAMnC;;OAEG;IACH,KAAK,IAAI,CAAC;IAIV;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;OAEG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAElC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,GAAG,SAAS,CAEvC;IAED;;OAEG;IACH,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAE3C;CACF;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagramWrapper Base Class
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class for diagram wrapper classes.
|
|
5
|
+
* Provides common functionality for building, mutating, and querying diagrams.
|
|
6
|
+
*
|
|
7
|
+
* Each diagram type (Flowchart, Sequence, Class, etc.) extends this base class
|
|
8
|
+
* and implements diagram-specific operations.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for diagram wrappers.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam T - The specific AST type this wrapper manages
|
|
14
|
+
*/
|
|
15
|
+
export class DiagramWrapper {
|
|
16
|
+
ast;
|
|
17
|
+
constructor(ast) {
|
|
18
|
+
this.ast = ast;
|
|
19
|
+
}
|
|
20
|
+
// ============================================
|
|
21
|
+
// Common Methods
|
|
22
|
+
// ============================================
|
|
23
|
+
/**
|
|
24
|
+
* Get the underlying AST
|
|
25
|
+
*/
|
|
26
|
+
toAST() {
|
|
27
|
+
return this.ast;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the diagram type
|
|
31
|
+
*/
|
|
32
|
+
get type() {
|
|
33
|
+
return this.ast.type;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the diagram title
|
|
37
|
+
*/
|
|
38
|
+
get title() {
|
|
39
|
+
return this.ast.title;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set the diagram title
|
|
43
|
+
*/
|
|
44
|
+
set title(value) {
|
|
45
|
+
this.ast.title = value;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the accessibility description
|
|
49
|
+
*/
|
|
50
|
+
get accDescription() {
|
|
51
|
+
return this.ast.accDescription;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set the accessibility description
|
|
55
|
+
*/
|
|
56
|
+
set accDescription(value) {
|
|
57
|
+
this.ast.accDescription = value;
|
|
58
|
+
}
|
|
59
|
+
}
|