@md2nativedocx/core 0.1.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 +15 -0
- package/dist/diagrams/architecture-diagram/parser.d.ts +29 -0
- package/dist/diagrams/architecture-diagram/parser.js +142 -0
- package/dist/diagrams/architecture-diagram/parser.js.map +1 -0
- package/dist/diagrams/architecture-diagram/translator.d.ts +41 -0
- package/dist/diagrams/architecture-diagram/translator.js +172 -0
- package/dist/diagrams/architecture-diagram/translator.js.map +1 -0
- package/dist/diagrams/architecture-diagram/types.d.ts +39 -0
- package/dist/diagrams/architecture-diagram/types.js +18 -0
- package/dist/diagrams/architecture-diagram/types.js.map +1 -0
- package/dist/diagrams/block/parser.d.ts +17 -0
- package/dist/diagrams/block/parser.js +312 -0
- package/dist/diagrams/block/parser.js.map +1 -0
- package/dist/diagrams/block/translator.d.ts +16 -0
- package/dist/diagrams/block/translator.js +137 -0
- package/dist/diagrams/block/translator.js.map +1 -0
- package/dist/diagrams/block/types.d.ts +38 -0
- package/dist/diagrams/block/types.js +6 -0
- package/dist/diagrams/block/types.js.map +1 -0
- package/dist/diagrams/c4/parser.d.ts +29 -0
- package/dist/diagrams/c4/parser.js +264 -0
- package/dist/diagrams/c4/parser.js.map +1 -0
- package/dist/diagrams/c4/translator.d.ts +50 -0
- package/dist/diagrams/c4/translator.js +240 -0
- package/dist/diagrams/c4/translator.js.map +1 -0
- package/dist/diagrams/c4/types.d.ts +74 -0
- package/dist/diagrams/c4/types.js +46 -0
- package/dist/diagrams/c4/types.js.map +1 -0
- package/dist/diagrams/class-diagram/parser.d.ts +40 -0
- package/dist/diagrams/class-diagram/parser.js +213 -0
- package/dist/diagrams/class-diagram/parser.js.map +1 -0
- package/dist/diagrams/class-diagram/translator.d.ts +48 -0
- package/dist/diagrams/class-diagram/translator.js +197 -0
- package/dist/diagrams/class-diagram/translator.js.map +1 -0
- package/dist/diagrams/class-diagram/types.d.ts +54 -0
- package/dist/diagrams/class-diagram/types.js +16 -0
- package/dist/diagrams/class-diagram/types.js.map +1 -0
- package/dist/diagrams/cynefin/parser.d.ts +24 -0
- package/dist/diagrams/cynefin/parser.js +102 -0
- package/dist/diagrams/cynefin/parser.js.map +1 -0
- package/dist/diagrams/cynefin/translator.d.ts +37 -0
- package/dist/diagrams/cynefin/translator.js +190 -0
- package/dist/diagrams/cynefin/translator.js.map +1 -0
- package/dist/diagrams/cynefin/types.d.ts +45 -0
- package/dist/diagrams/cynefin/types.js +36 -0
- package/dist/diagrams/cynefin/types.js.map +1 -0
- package/dist/diagrams/er-diagram/parser.d.ts +29 -0
- package/dist/diagrams/er-diagram/parser.js +156 -0
- package/dist/diagrams/er-diagram/parser.js.map +1 -0
- package/dist/diagrams/er-diagram/translator.d.ts +26 -0
- package/dist/diagrams/er-diagram/translator.js +151 -0
- package/dist/diagrams/er-diagram/translator.js.map +1 -0
- package/dist/diagrams/er-diagram/types.d.ts +44 -0
- package/dist/diagrams/er-diagram/types.js +17 -0
- package/dist/diagrams/er-diagram/types.js.map +1 -0
- package/dist/diagrams/event-modeling/parser.d.ts +16 -0
- package/dist/diagrams/event-modeling/parser.js +193 -0
- package/dist/diagrams/event-modeling/parser.js.map +1 -0
- package/dist/diagrams/event-modeling/translator.d.ts +17 -0
- package/dist/diagrams/event-modeling/translator.js +154 -0
- package/dist/diagrams/event-modeling/translator.js.map +1 -0
- package/dist/diagrams/event-modeling/types.d.ts +46 -0
- package/dist/diagrams/event-modeling/types.js +6 -0
- package/dist/diagrams/event-modeling/types.js.map +1 -0
- package/dist/diagrams/gantt/date-utils.d.ts +51 -0
- package/dist/diagrams/gantt/date-utils.js +131 -0
- package/dist/diagrams/gantt/date-utils.js.map +1 -0
- package/dist/diagrams/gantt/parser.d.ts +37 -0
- package/dist/diagrams/gantt/parser.js +221 -0
- package/dist/diagrams/gantt/parser.js.map +1 -0
- package/dist/diagrams/gantt/translator.d.ts +23 -0
- package/dist/diagrams/gantt/translator.js +259 -0
- package/dist/diagrams/gantt/translator.js.map +1 -0
- package/dist/diagrams/gantt/types.d.ts +31 -0
- package/dist/diagrams/gantt/types.js +14 -0
- package/dist/diagrams/gantt/types.js.map +1 -0
- package/dist/diagrams/git-graph/parser.d.ts +29 -0
- package/dist/diagrams/git-graph/parser.js +237 -0
- package/dist/diagrams/git-graph/parser.js.map +1 -0
- package/dist/diagrams/git-graph/translator.d.ts +49 -0
- package/dist/diagrams/git-graph/translator.js +224 -0
- package/dist/diagrams/git-graph/translator.js.map +1 -0
- package/dist/diagrams/git-graph/types.d.ts +72 -0
- package/dist/diagrams/git-graph/types.js +35 -0
- package/dist/diagrams/git-graph/types.js.map +1 -0
- package/dist/diagrams/ishikawa/parser.d.ts +15 -0
- package/dist/diagrams/ishikawa/parser.js +85 -0
- package/dist/diagrams/ishikawa/parser.js.map +1 -0
- package/dist/diagrams/ishikawa/translator.d.ts +12 -0
- package/dist/diagrams/ishikawa/translator.js +95 -0
- package/dist/diagrams/ishikawa/translator.js.map +1 -0
- package/dist/diagrams/ishikawa/types.d.ts +19 -0
- package/dist/diagrams/ishikawa/types.js +6 -0
- package/dist/diagrams/ishikawa/types.js.map +1 -0
- package/dist/diagrams/journey/parser.d.ts +14 -0
- package/dist/diagrams/journey/parser.js +78 -0
- package/dist/diagrams/journey/parser.js.map +1 -0
- package/dist/diagrams/journey/translator.d.ts +11 -0
- package/dist/diagrams/journey/translator.js +90 -0
- package/dist/diagrams/journey/translator.js.map +1 -0
- package/dist/diagrams/journey/types.d.ts +20 -0
- package/dist/diagrams/journey/types.js +6 -0
- package/dist/diagrams/journey/types.js.map +1 -0
- package/dist/diagrams/kanban/parser.d.ts +17 -0
- package/dist/diagrams/kanban/parser.js +129 -0
- package/dist/diagrams/kanban/parser.js.map +1 -0
- package/dist/diagrams/kanban/translator.d.ts +13 -0
- package/dist/diagrams/kanban/translator.js +72 -0
- package/dist/diagrams/kanban/translator.js.map +1 -0
- package/dist/diagrams/kanban/types.d.ts +21 -0
- package/dist/diagrams/kanban/types.js +6 -0
- package/dist/diagrams/kanban/types.js.map +1 -0
- package/dist/diagrams/mindmap/parser.d.ts +23 -0
- package/dist/diagrams/mindmap/parser.js +108 -0
- package/dist/diagrams/mindmap/parser.js.map +1 -0
- package/dist/diagrams/mindmap/translator.d.ts +31 -0
- package/dist/diagrams/mindmap/translator.js +249 -0
- package/dist/diagrams/mindmap/translator.js.map +1 -0
- package/dist/diagrams/mindmap/types.d.ts +19 -0
- package/dist/diagrams/mindmap/types.js +10 -0
- package/dist/diagrams/mindmap/types.js.map +1 -0
- package/dist/diagrams/packet/parser.d.ts +15 -0
- package/dist/diagrams/packet/parser.js +99 -0
- package/dist/diagrams/packet/parser.js.map +1 -0
- package/dist/diagrams/packet/translator.d.ts +14 -0
- package/dist/diagrams/packet/translator.js +66 -0
- package/dist/diagrams/packet/translator.js.map +1 -0
- package/dist/diagrams/packet/types.d.ts +14 -0
- package/dist/diagrams/packet/types.js +6 -0
- package/dist/diagrams/packet/types.js.map +1 -0
- package/dist/diagrams/pie/chart.d.ts +26 -0
- package/dist/diagrams/pie/chart.js +64 -0
- package/dist/diagrams/pie/chart.js.map +1 -0
- package/dist/diagrams/pie/parser.d.ts +18 -0
- package/dist/diagrams/pie/parser.js +93 -0
- package/dist/diagrams/pie/parser.js.map +1 -0
- package/dist/diagrams/pie/translator.d.ts +15 -0
- package/dist/diagrams/pie/translator.js +150 -0
- package/dist/diagrams/pie/translator.js.map +1 -0
- package/dist/diagrams/pie/types.d.ts +16 -0
- package/dist/diagrams/pie/types.js +6 -0
- package/dist/diagrams/pie/types.js.map +1 -0
- package/dist/diagrams/quadrant/parser.d.ts +24 -0
- package/dist/diagrams/quadrant/parser.js +96 -0
- package/dist/diagrams/quadrant/parser.js.map +1 -0
- package/dist/diagrams/quadrant/translator.d.ts +21 -0
- package/dist/diagrams/quadrant/translator.js +204 -0
- package/dist/diagrams/quadrant/translator.js.map +1 -0
- package/dist/diagrams/quadrant/types.d.ts +41 -0
- package/dist/diagrams/quadrant/types.js +10 -0
- package/dist/diagrams/quadrant/types.js.map +1 -0
- package/dist/diagrams/radar/chart.d.ts +21 -0
- package/dist/diagrams/radar/chart.js +65 -0
- package/dist/diagrams/radar/chart.js.map +1 -0
- package/dist/diagrams/radar/parser.d.ts +15 -0
- package/dist/diagrams/radar/parser.js +186 -0
- package/dist/diagrams/radar/parser.js.map +1 -0
- package/dist/diagrams/radar/translator.d.ts +12 -0
- package/dist/diagrams/radar/translator.js +98 -0
- package/dist/diagrams/radar/translator.js.map +1 -0
- package/dist/diagrams/radar/types.d.ts +29 -0
- package/dist/diagrams/radar/types.js +6 -0
- package/dist/diagrams/radar/types.js.map +1 -0
- package/dist/diagrams/requirement-diagram/parser.d.ts +29 -0
- package/dist/diagrams/requirement-diagram/parser.js +156 -0
- package/dist/diagrams/requirement-diagram/parser.js.map +1 -0
- package/dist/diagrams/requirement-diagram/translator.d.ts +24 -0
- package/dist/diagrams/requirement-diagram/translator.js +214 -0
- package/dist/diagrams/requirement-diagram/translator.js.map +1 -0
- package/dist/diagrams/requirement-diagram/types.d.ts +37 -0
- package/dist/diagrams/requirement-diagram/types.js +18 -0
- package/dist/diagrams/requirement-diagram/types.js.map +1 -0
- package/dist/diagrams/sankey/parser.d.ts +14 -0
- package/dist/diagrams/sankey/parser.js +123 -0
- package/dist/diagrams/sankey/parser.js.map +1 -0
- package/dist/diagrams/sankey/translator.d.ts +15 -0
- package/dist/diagrams/sankey/translator.js +132 -0
- package/dist/diagrams/sankey/translator.js.map +1 -0
- package/dist/diagrams/sankey/types.d.ts +16 -0
- package/dist/diagrams/sankey/types.js +6 -0
- package/dist/diagrams/sankey/types.js.map +1 -0
- package/dist/diagrams/sequence/parser.d.ts +22 -0
- package/dist/diagrams/sequence/parser.js +256 -0
- package/dist/diagrams/sequence/parser.js.map +1 -0
- package/dist/diagrams/sequence/translator.d.ts +21 -0
- package/dist/diagrams/sequence/translator.js +309 -0
- package/dist/diagrams/sequence/translator.js.map +1 -0
- package/dist/diagrams/sequence/types.d.ts +62 -0
- package/dist/diagrams/sequence/types.js +8 -0
- package/dist/diagrams/sequence/types.js.map +1 -0
- package/dist/diagrams/state-diagram/parser.d.ts +37 -0
- package/dist/diagrams/state-diagram/parser.js +215 -0
- package/dist/diagrams/state-diagram/parser.js.map +1 -0
- package/dist/diagrams/state-diagram/translator.d.ts +25 -0
- package/dist/diagrams/state-diagram/translator.js +165 -0
- package/dist/diagrams/state-diagram/translator.js.map +1 -0
- package/dist/diagrams/state-diagram/types.d.ts +38 -0
- package/dist/diagrams/state-diagram/types.js +13 -0
- package/dist/diagrams/state-diagram/types.js.map +1 -0
- package/dist/diagrams/timeline/parser.d.ts +17 -0
- package/dist/diagrams/timeline/parser.js +82 -0
- package/dist/diagrams/timeline/parser.js.map +1 -0
- package/dist/diagrams/timeline/translator.d.ts +13 -0
- package/dist/diagrams/timeline/translator.js +90 -0
- package/dist/diagrams/timeline/translator.js.map +1 -0
- package/dist/diagrams/timeline/types.d.ts +18 -0
- package/dist/diagrams/timeline/types.js +6 -0
- package/dist/diagrams/timeline/types.js.map +1 -0
- package/dist/diagrams/tree-view/parser.d.ts +16 -0
- package/dist/diagrams/tree-view/parser.js +129 -0
- package/dist/diagrams/tree-view/parser.js.map +1 -0
- package/dist/diagrams/tree-view/translator.d.ts +11 -0
- package/dist/diagrams/tree-view/translator.js +73 -0
- package/dist/diagrams/tree-view/translator.js.map +1 -0
- package/dist/diagrams/tree-view/types.d.ts +22 -0
- package/dist/diagrams/tree-view/types.js +6 -0
- package/dist/diagrams/tree-view/types.js.map +1 -0
- package/dist/diagrams/treemap/parser.d.ts +15 -0
- package/dist/diagrams/treemap/parser.js +131 -0
- package/dist/diagrams/treemap/parser.js.map +1 -0
- package/dist/diagrams/treemap/translator.d.ts +15 -0
- package/dist/diagrams/treemap/translator.js +136 -0
- package/dist/diagrams/treemap/translator.js.map +1 -0
- package/dist/diagrams/treemap/types.d.ts +22 -0
- package/dist/diagrams/treemap/types.js +6 -0
- package/dist/diagrams/treemap/types.js.map +1 -0
- package/dist/diagrams/venn/parser.d.ts +27 -0
- package/dist/diagrams/venn/parser.js +129 -0
- package/dist/diagrams/venn/parser.js.map +1 -0
- package/dist/diagrams/venn/translator.d.ts +25 -0
- package/dist/diagrams/venn/translator.js +214 -0
- package/dist/diagrams/venn/translator.js.map +1 -0
- package/dist/diagrams/venn/types.d.ts +33 -0
- package/dist/diagrams/venn/types.js +11 -0
- package/dist/diagrams/venn/types.js.map +1 -0
- package/dist/diagrams/wardley/parser.d.ts +14 -0
- package/dist/diagrams/wardley/parser.js +254 -0
- package/dist/diagrams/wardley/parser.js.map +1 -0
- package/dist/diagrams/wardley/translator.d.ts +15 -0
- package/dist/diagrams/wardley/translator.js +196 -0
- package/dist/diagrams/wardley/translator.js.map +1 -0
- package/dist/diagrams/wardley/types.d.ts +74 -0
- package/dist/diagrams/wardley/types.js +8 -0
- package/dist/diagrams/wardley/types.js.map +1 -0
- package/dist/diagrams/xychart/chart.d.ts +24 -0
- package/dist/diagrams/xychart/chart.js +113 -0
- package/dist/diagrams/xychart/chart.js.map +1 -0
- package/dist/diagrams/xychart/parser.d.ts +16 -0
- package/dist/diagrams/xychart/parser.js +190 -0
- package/dist/diagrams/xychart/parser.js.map +1 -0
- package/dist/diagrams/xychart/translator.d.ts +14 -0
- package/dist/diagrams/xychart/translator.js +187 -0
- package/dist/diagrams/xychart/translator.js.map +1 -0
- package/dist/diagrams/xychart/types.d.ts +32 -0
- package/dist/diagrams/xychart/types.js +6 -0
- package/dist/diagrams/xychart/types.js.map +1 -0
- package/dist/diagrams/zenuml/parser.d.ts +21 -0
- package/dist/diagrams/zenuml/parser.js +228 -0
- package/dist/diagrams/zenuml/parser.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/dist/label-runs.d.ts +16 -0
- package/dist/label-runs.js +30 -0
- package/dist/label-runs.js.map +1 -0
- package/dist/layout/layout.d.ts +53 -0
- package/dist/layout/layout.js +536 -0
- package/dist/layout/layout.js.map +1 -0
- package/dist/parser/diagram-type.d.ts +41 -0
- package/dist/parser/diagram-type.js +97 -0
- package/dist/parser/diagram-type.js.map +1 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +2 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +1134 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/render-diagram.d.ts +156 -0
- package/dist/render-diagram.js +326 -0
- package/dist/render-diagram.js.map +1 -0
- package/dist/rendering-plan.d.ts +47 -0
- package/dist/rendering-plan.js +43 -0
- package/dist/rendering-plan.js.map +1 -0
- package/dist/smartart/chain.d.ts +216 -0
- package/dist/smartart/chain.js +558 -0
- package/dist/smartart/chain.js.map +1 -0
- package/dist/smartart/classify.d.ts +96 -0
- package/dist/smartart/classify.js +162 -0
- package/dist/smartart/classify.js.map +1 -0
- package/dist/smartart/cycle.d.ts +91 -0
- package/dist/smartart/cycle.js +323 -0
- package/dist/smartart/cycle.js.map +1 -0
- package/dist/smartart/dispatch.d.ts +48 -0
- package/dist/smartart/dispatch.js +49 -0
- package/dist/smartart/dispatch.js.map +1 -0
- package/dist/smartart/drawing.d.ts +155 -0
- package/dist/smartart/drawing.js +574 -0
- package/dist/smartart/drawing.js.map +1 -0
- package/dist/smartart/embed.d.ts +78 -0
- package/dist/smartart/embed.js +136 -0
- package/dist/smartart/embed.js.map +1 -0
- package/dist/smartart/from-graph.d.ts +42 -0
- package/dist/smartart/from-graph.js +106 -0
- package/dist/smartart/from-graph.js.map +1 -0
- package/dist/smartart/from-timeline.d.ts +30 -0
- package/dist/smartart/from-timeline.js +59 -0
- package/dist/smartart/from-timeline.js.map +1 -0
- package/dist/smartart/from-tree.d.ts +36 -0
- package/dist/smartart/from-tree.js +74 -0
- package/dist/smartart/from-tree.js.map +1 -0
- package/dist/smartart/generate-options.d.ts +12 -0
- package/dist/smartart/generate-options.js +2 -0
- package/dist/smartart/generate-options.js.map +1 -0
- package/dist/smartart/kanban.d.ts +24 -0
- package/dist/smartart/kanban.js +250 -0
- package/dist/smartart/kanban.js.map +1 -0
- package/dist/smartart/node-shape.d.ts +16 -0
- package/dist/smartart/node-shape.js +22 -0
- package/dist/smartart/node-shape.js.map +1 -0
- package/dist/smartart/styles.d.ts +114 -0
- package/dist/smartart/styles.js +141 -0
- package/dist/smartart/styles.js.map +1 -0
- package/dist/smartart/text.d.ts +16 -0
- package/dist/smartart/text.js +48 -0
- package/dist/smartart/text.js.map +1 -0
- package/dist/smartart/timeline-grouped.d.ts +40 -0
- package/dist/smartart/timeline-grouped.js +279 -0
- package/dist/smartart/timeline-grouped.js.map +1 -0
- package/dist/smartart/timeline.d.ts +51 -0
- package/dist/smartart/timeline.js +276 -0
- package/dist/smartart/timeline.js.map +1 -0
- package/dist/smartart/tree-deep.d.ts +61 -0
- package/dist/smartart/tree-deep.js +293 -0
- package/dist/smartart/tree-deep.js.map +1 -0
- package/dist/smartart/tree.d.ts +159 -0
- package/dist/smartart/tree.js +497 -0
- package/dist/smartart/tree.js.map +1 -0
- package/dist/translator/boxes.d.ts +36 -0
- package/dist/translator/boxes.js +95 -0
- package/dist/translator/boxes.js.map +1 -0
- package/dist/translator/canvas.d.ts +82 -0
- package/dist/translator/canvas.js +135 -0
- package/dist/translator/canvas.js.map +1 -0
- package/dist/translator/graph-shapes.d.ts +98 -0
- package/dist/translator/graph-shapes.js +223 -0
- package/dist/translator/graph-shapes.js.map +1 -0
- package/dist/translator/native-chart.d.ts +64 -0
- package/dist/translator/native-chart.js +109 -0
- package/dist/translator/native-chart.js.map +1 -0
- package/dist/translator/ooxml-translator.d.ts +79 -0
- package/dist/translator/ooxml-translator.js +1213 -0
- package/dist/translator/ooxml-translator.js.map +1 -0
- package/dist/translator/path-shape.d.ts +11 -0
- package/dist/translator/path-shape.js +37 -0
- package/dist/translator/path-shape.js.map +1 -0
- package/dist/translator/unsupported-diagram-note.d.ts +16 -0
- package/dist/translator/unsupported-diagram-note.js +34 -0
- package/dist/translator/unsupported-diagram-note.js.map +1 -0
- package/dist/translator/xml-escape.d.ts +28 -0
- package/dist/translator/xml-escape.js +40 -0
- package/dist/translator/xml-escape.js.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intermediate AST for a Mermaid C4 diagram (`C4Context`/`C4Container`/
|
|
3
|
+
* `C4Component`/`C4Dynamic`/`C4Deployment` — Family B,
|
|
4
|
+
* `docs/specs/FUTURE_full_mermaid_coverage_SPEC.md` §3: "proche flowchart
|
|
5
|
+
* mais notation fonctionnelle `Rel(a,b,\"...\")`"). All 5 header keywords
|
|
6
|
+
* produce the same AST shape: this project has no notion of C4's "levels"
|
|
7
|
+
* beyond which element types happen to appear, since layout/rendering don't
|
|
8
|
+
* differ between them. Grammar verified against the real
|
|
9
|
+
* `mermaid-js/mermaid` docs source (`docs/syntax/c4.md`, fetched 2026-09-11
|
|
10
|
+
* via raw.githubusercontent.com — the rendered mermaid.js.org page embeds
|
|
11
|
+
* its example code in an interactive editor that a text-only fetch can't
|
|
12
|
+
* read) — a PlantUML-compatible function-call syntax, itself still marked
|
|
13
|
+
* "experimental" by Mermaid's own docs.
|
|
14
|
+
*
|
|
15
|
+
* V1 scope, deliberately (see `parser.ts`'s doc comment for the rest):
|
|
16
|
+
* - Every element type (`Person(_Ext)`, `System(Db/Queue)(_Ext)`,
|
|
17
|
+
* `Container(Db/Queue)(_Ext)`, `Component(Db/Queue)(_Ext)`,
|
|
18
|
+
* `Deployment_Node`/`Node`/`Node_L`/`Node_R`) collapses onto one
|
|
19
|
+
* `C4Element` shape: a `category` (person/system/container/component/
|
|
20
|
+
* node), an `external` flag, and an optional `variant` (db/queue) — the
|
|
21
|
+
* `_Ext` suffix and the `Db`/`Queue` infix are the only two orthogonal
|
|
22
|
+
* axes Mermaid's naming scheme actually varies; alignment hints
|
|
23
|
+
* (`Node_L`/`Node_R`) and sprite/tag/link decorations are parsed away
|
|
24
|
+
* with no AST effect (unsupported even in real Mermaid — see the docs'
|
|
25
|
+
* own "unfinished features" list).
|
|
26
|
+
* - `Boundary`/`Enterprise_Boundary`/`System_Boundary`/`Container_Boundary`
|
|
27
|
+
* nesting, and a `Deployment_Node` used as a wrapper, are tracked only as
|
|
28
|
+
* `parent` on the elements declared inside — same flattened-with-warning
|
|
29
|
+
* shape as `architecture-beta`'s `in <parent>` and `classDiagram`'s
|
|
30
|
+
* `namespace` (see `translator.ts`'s doc comment for why real nested
|
|
31
|
+
* containment isn't v1).
|
|
32
|
+
* - `Rel`/`BiRel`/`Rel_Back`/`Rel_U`/`Rel_Up`/`Rel_D`/`Rel_Down`/`Rel_L`/
|
|
33
|
+
* `Rel_Left`/`Rel_R`/`Rel_Right`/`RelIndex` all collapse onto one
|
|
34
|
+
* `C4Relationship` shape — the directional variants exist in real C4-
|
|
35
|
+
* PlantUML only as a manual-layout hint (mermaid's own docs: "there is no
|
|
36
|
+
* plan to support" `Lay_*` statements, and these `Rel_*` suffixes don't
|
|
37
|
+
* affect Mermaid's own rendering either), and `RelIndex`'s leading
|
|
38
|
+
* `index` argument is dropped (Mermaid's own docs: "ignores the index
|
|
39
|
+
* parameter").
|
|
40
|
+
* - `UpdateElementStyle`/`UpdateRelStyle`/`UpdateLayoutConfig`/
|
|
41
|
+
* `AddElementTag`/`AddRelTag` are recognized and warned once, never
|
|
42
|
+
* silently dropped, but have no AST/rendering effect in v1 (pure styling/
|
|
43
|
+
* layout-density directives, not structure).
|
|
44
|
+
*/
|
|
45
|
+
export type C4Category = 'person' | 'system' | 'container' | 'component' | 'node';
|
|
46
|
+
export type C4Variant = 'db' | 'queue';
|
|
47
|
+
export interface C4Element {
|
|
48
|
+
id: string;
|
|
49
|
+
category: C4Category;
|
|
50
|
+
external: boolean;
|
|
51
|
+
variant?: C4Variant;
|
|
52
|
+
label: string;
|
|
53
|
+
/** The `?techn`/`?type` positional argument (technology for Container/
|
|
54
|
+
* Component, OS/platform for a Deployment_Node) — same display slot for
|
|
55
|
+
* every category, so one field suffices. */
|
|
56
|
+
techn?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
/** The enclosing `Boundary`/`Enterprise_Boundary`/`System_Boundary`/
|
|
59
|
+
* `Container_Boundary`/`Deployment_Node` id, if any. Not rendered as
|
|
60
|
+
* visual containment in v1 — see `translator.ts`. */
|
|
61
|
+
parent?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface C4Relationship {
|
|
64
|
+
from: string;
|
|
65
|
+
to: string;
|
|
66
|
+
label: string;
|
|
67
|
+
techn?: string;
|
|
68
|
+
bidirectional: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface C4Diagram {
|
|
71
|
+
title?: string;
|
|
72
|
+
elements: C4Element[];
|
|
73
|
+
relationships: C4Relationship[];
|
|
74
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intermediate AST for a Mermaid C4 diagram (`C4Context`/`C4Container`/
|
|
3
|
+
* `C4Component`/`C4Dynamic`/`C4Deployment` — Family B,
|
|
4
|
+
* `docs/specs/FUTURE_full_mermaid_coverage_SPEC.md` §3: "proche flowchart
|
|
5
|
+
* mais notation fonctionnelle `Rel(a,b,\"...\")`"). All 5 header keywords
|
|
6
|
+
* produce the same AST shape: this project has no notion of C4's "levels"
|
|
7
|
+
* beyond which element types happen to appear, since layout/rendering don't
|
|
8
|
+
* differ between them. Grammar verified against the real
|
|
9
|
+
* `mermaid-js/mermaid` docs source (`docs/syntax/c4.md`, fetched 2026-09-11
|
|
10
|
+
* via raw.githubusercontent.com — the rendered mermaid.js.org page embeds
|
|
11
|
+
* its example code in an interactive editor that a text-only fetch can't
|
|
12
|
+
* read) — a PlantUML-compatible function-call syntax, itself still marked
|
|
13
|
+
* "experimental" by Mermaid's own docs.
|
|
14
|
+
*
|
|
15
|
+
* V1 scope, deliberately (see `parser.ts`'s doc comment for the rest):
|
|
16
|
+
* - Every element type (`Person(_Ext)`, `System(Db/Queue)(_Ext)`,
|
|
17
|
+
* `Container(Db/Queue)(_Ext)`, `Component(Db/Queue)(_Ext)`,
|
|
18
|
+
* `Deployment_Node`/`Node`/`Node_L`/`Node_R`) collapses onto one
|
|
19
|
+
* `C4Element` shape: a `category` (person/system/container/component/
|
|
20
|
+
* node), an `external` flag, and an optional `variant` (db/queue) — the
|
|
21
|
+
* `_Ext` suffix and the `Db`/`Queue` infix are the only two orthogonal
|
|
22
|
+
* axes Mermaid's naming scheme actually varies; alignment hints
|
|
23
|
+
* (`Node_L`/`Node_R`) and sprite/tag/link decorations are parsed away
|
|
24
|
+
* with no AST effect (unsupported even in real Mermaid — see the docs'
|
|
25
|
+
* own "unfinished features" list).
|
|
26
|
+
* - `Boundary`/`Enterprise_Boundary`/`System_Boundary`/`Container_Boundary`
|
|
27
|
+
* nesting, and a `Deployment_Node` used as a wrapper, are tracked only as
|
|
28
|
+
* `parent` on the elements declared inside — same flattened-with-warning
|
|
29
|
+
* shape as `architecture-beta`'s `in <parent>` and `classDiagram`'s
|
|
30
|
+
* `namespace` (see `translator.ts`'s doc comment for why real nested
|
|
31
|
+
* containment isn't v1).
|
|
32
|
+
* - `Rel`/`BiRel`/`Rel_Back`/`Rel_U`/`Rel_Up`/`Rel_D`/`Rel_Down`/`Rel_L`/
|
|
33
|
+
* `Rel_Left`/`Rel_R`/`Rel_Right`/`RelIndex` all collapse onto one
|
|
34
|
+
* `C4Relationship` shape — the directional variants exist in real C4-
|
|
35
|
+
* PlantUML only as a manual-layout hint (mermaid's own docs: "there is no
|
|
36
|
+
* plan to support" `Lay_*` statements, and these `Rel_*` suffixes don't
|
|
37
|
+
* affect Mermaid's own rendering either), and `RelIndex`'s leading
|
|
38
|
+
* `index` argument is dropped (Mermaid's own docs: "ignores the index
|
|
39
|
+
* parameter").
|
|
40
|
+
* - `UpdateElementStyle`/`UpdateRelStyle`/`UpdateLayoutConfig`/
|
|
41
|
+
* `AddElementTag`/`AddRelTag` are recognized and warned once, never
|
|
42
|
+
* silently dropped, but have no AST/rendering effect in v1 (pure styling/
|
|
43
|
+
* layout-density directives, not structure).
|
|
44
|
+
*/
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/diagrams/c4/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser for Mermaid `classDiagram` (grammar verified against
|
|
3
|
+
* mermaid.js.org/syntax/classDiagram.html, fetched 2026-09-09). Line-oriented,
|
|
4
|
+
* same forgiving convention as `../../parser/parser.ts` and
|
|
5
|
+
* `../quadrant/parser.ts`: an unrecognized line is skipped with a warning
|
|
6
|
+
* rather than throwing.
|
|
7
|
+
*
|
|
8
|
+
* V1 scope, deliberately:
|
|
9
|
+
* - Class declaration (`class Name`, `class Name["Label"]`, `class Name { ... }`,
|
|
10
|
+
* backtick-quoted ids) and its member block (colon or bracket member
|
|
11
|
+
* syntax — kept as raw display text, see `types.ts`).
|
|
12
|
+
* - All 8 relationship arrow families with an optional `: Label` suffix.
|
|
13
|
+
* - `direction TD|TB|LR|BT|RL` (same TB->TD normalization as flowchart).
|
|
14
|
+
*
|
|
15
|
+
* NOT implemented yet, each degrading to "recognized and warned", never
|
|
16
|
+
* silently dropped:
|
|
17
|
+
* - Generics (`List~int~`) — the `~...~` suffix is stripped from the id
|
|
18
|
+
* with no warning (harmless: the base id is exactly what relationships
|
|
19
|
+
* reference too), but the generic itself is not displayed.
|
|
20
|
+
* - Annotations (`<<Interface>>`), inline or on their own line outside a
|
|
21
|
+
* class block, and `namespace` blocks — recognized (a `namespace ... {`
|
|
22
|
+
* line, or a class body's own `<<...>>` first line) and warned, not
|
|
23
|
+
* parsed. `namespace` grouping is lost but the `class` declarations
|
|
24
|
+
* nested inside one are still parsed correctly (see the generic brace
|
|
25
|
+
* stack below) — only the visual grouping/label is dropped.
|
|
26
|
+
* - `classDef`/`style`/`cssClass` styling and relationship cardinalities
|
|
27
|
+
* (`"1"`, `"0..1"`, ...) — cardinalities are stripped (quoted segments
|
|
28
|
+
* removed before relationship matching) with a warning; styling lines are
|
|
29
|
+
* warned and skipped entirely.
|
|
30
|
+
* - `note`/`note for` — warned and skipped.
|
|
31
|
+
*
|
|
32
|
+
* None of the above affects which classes/members/relationships end up in
|
|
33
|
+
* the AST — only cosmetic extras a first version can safely leave out.
|
|
34
|
+
*/
|
|
35
|
+
import type { ClassDiagram } from './types.js';
|
|
36
|
+
export interface ClassDiagramParseResult {
|
|
37
|
+
ast: ClassDiagram;
|
|
38
|
+
warnings: string[];
|
|
39
|
+
}
|
|
40
|
+
export declare function parseClassDiagram(text: string): ClassDiagramParseResult;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser for Mermaid `classDiagram` (grammar verified against
|
|
3
|
+
* mermaid.js.org/syntax/classDiagram.html, fetched 2026-09-09). Line-oriented,
|
|
4
|
+
* same forgiving convention as `../../parser/parser.ts` and
|
|
5
|
+
* `../quadrant/parser.ts`: an unrecognized line is skipped with a warning
|
|
6
|
+
* rather than throwing.
|
|
7
|
+
*
|
|
8
|
+
* V1 scope, deliberately:
|
|
9
|
+
* - Class declaration (`class Name`, `class Name["Label"]`, `class Name { ... }`,
|
|
10
|
+
* backtick-quoted ids) and its member block (colon or bracket member
|
|
11
|
+
* syntax — kept as raw display text, see `types.ts`).
|
|
12
|
+
* - All 8 relationship arrow families with an optional `: Label` suffix.
|
|
13
|
+
* - `direction TD|TB|LR|BT|RL` (same TB->TD normalization as flowchart).
|
|
14
|
+
*
|
|
15
|
+
* NOT implemented yet, each degrading to "recognized and warned", never
|
|
16
|
+
* silently dropped:
|
|
17
|
+
* - Generics (`List~int~`) — the `~...~` suffix is stripped from the id
|
|
18
|
+
* with no warning (harmless: the base id is exactly what relationships
|
|
19
|
+
* reference too), but the generic itself is not displayed.
|
|
20
|
+
* - Annotations (`<<Interface>>`), inline or on their own line outside a
|
|
21
|
+
* class block, and `namespace` blocks — recognized (a `namespace ... {`
|
|
22
|
+
* line, or a class body's own `<<...>>` first line) and warned, not
|
|
23
|
+
* parsed. `namespace` grouping is lost but the `class` declarations
|
|
24
|
+
* nested inside one are still parsed correctly (see the generic brace
|
|
25
|
+
* stack below) — only the visual grouping/label is dropped.
|
|
26
|
+
* - `classDef`/`style`/`cssClass` styling and relationship cardinalities
|
|
27
|
+
* (`"1"`, `"0..1"`, ...) — cardinalities are stripped (quoted segments
|
|
28
|
+
* removed before relationship matching) with a warning; styling lines are
|
|
29
|
+
* warned and skipped entirely.
|
|
30
|
+
* - `note`/`note for` — warned and skipped.
|
|
31
|
+
*
|
|
32
|
+
* None of the above affects which classes/members/relationships end up in
|
|
33
|
+
* the AST — only cosmetic extras a first version can safely leave out.
|
|
34
|
+
*/
|
|
35
|
+
// Longest-prefix-first so e.g. `..|>` doesn't get cut short by `..` or `..>`.
|
|
36
|
+
const REL_TOKEN_PATTERN = '<\\|--|--\\|>|\\.\\.\\|>|\\|>\\.\\.|\\.\\.>|<\\.\\.|--\\*|\\*--|--o|o--|-->|<--|--|\\.\\.';
|
|
37
|
+
const REL_LINE = new RegExp(`^(\\S+)\\s*(${REL_TOKEN_PATTERN})\\s*(\\S+)\\s*(?::\\s*(.+))?$`);
|
|
38
|
+
const REL_INFO = {
|
|
39
|
+
'<|--': { type: 'inheritance', markerEnd: 'from' },
|
|
40
|
+
'--|>': { type: 'inheritance', markerEnd: 'to' },
|
|
41
|
+
'*--': { type: 'composition', markerEnd: 'from' },
|
|
42
|
+
'--*': { type: 'composition', markerEnd: 'to' },
|
|
43
|
+
'o--': { type: 'aggregation', markerEnd: 'from' },
|
|
44
|
+
'--o': { type: 'aggregation', markerEnd: 'to' },
|
|
45
|
+
'-->': { type: 'association', markerEnd: 'to' },
|
|
46
|
+
'<--': { type: 'association', markerEnd: 'from' },
|
|
47
|
+
'..>': { type: 'dependency', markerEnd: 'to' },
|
|
48
|
+
'<..': { type: 'dependency', markerEnd: 'from' },
|
|
49
|
+
'..|>': { type: 'realization', markerEnd: 'to' },
|
|
50
|
+
'|>..': { type: 'realization', markerEnd: 'from' },
|
|
51
|
+
'--': { type: 'link', markerEnd: 'none' },
|
|
52
|
+
'..': { type: 'dashedLink', markerEnd: 'none' },
|
|
53
|
+
};
|
|
54
|
+
const CLASS_HEADER = new RegExp('^class\\s+(?:`([^`]+)`|([A-Za-z_$][\\w$]*))(?:~[^~]*~)?' +
|
|
55
|
+
'(?:\\[(?:"([^"]*)"|([^\\]]*))\\])?\\s*(\\{)?\\s*$', 'i');
|
|
56
|
+
function stripQuotedSegments(line) {
|
|
57
|
+
let hadQuoted = false;
|
|
58
|
+
const clean = line
|
|
59
|
+
.replace(/"[^"]*"/g, () => {
|
|
60
|
+
hadQuoted = true;
|
|
61
|
+
return ' ';
|
|
62
|
+
})
|
|
63
|
+
.replace(/\s+/g, ' ')
|
|
64
|
+
.trim();
|
|
65
|
+
return { clean, hadQuoted };
|
|
66
|
+
}
|
|
67
|
+
function stripIdQuotes(id) {
|
|
68
|
+
return id.replace(/^`|`$/g, '').trim();
|
|
69
|
+
}
|
|
70
|
+
export function parseClassDiagram(text) {
|
|
71
|
+
const warnings = [];
|
|
72
|
+
const classes = new Map();
|
|
73
|
+
const relationships = [];
|
|
74
|
+
let direction = 'TD';
|
|
75
|
+
function getOrCreateClass(id) {
|
|
76
|
+
let box = classes.get(id);
|
|
77
|
+
if (!box) {
|
|
78
|
+
box = { id, label: id, attributes: [], methods: [] };
|
|
79
|
+
classes.set(id, box);
|
|
80
|
+
}
|
|
81
|
+
return box;
|
|
82
|
+
}
|
|
83
|
+
const stack = [];
|
|
84
|
+
let warnedNamespace = false;
|
|
85
|
+
let warnedAnnotation = false;
|
|
86
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
87
|
+
const line = rawLine.trim();
|
|
88
|
+
if (line.length === 0 || line.startsWith('%%'))
|
|
89
|
+
continue;
|
|
90
|
+
if (/^classDiagram\b/i.test(line))
|
|
91
|
+
continue;
|
|
92
|
+
const top = stack[stack.length - 1];
|
|
93
|
+
if (line === '}') {
|
|
94
|
+
if (stack.length > 0)
|
|
95
|
+
stack.pop();
|
|
96
|
+
else
|
|
97
|
+
warnings.push(`Unexpected "}" without a matching block opener: ${line}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (top?.kind === 'class') {
|
|
101
|
+
if (/^<<.*>>$/.test(line)) {
|
|
102
|
+
if (!warnedAnnotation) {
|
|
103
|
+
warnings.push('Class annotations (e.g. <<Interface>>) are not yet rendered, ignored.');
|
|
104
|
+
warnedAnnotation = true;
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const visMatch = line.match(/^([+\-#~])\s*(.+)$/);
|
|
109
|
+
const visibility = visMatch ? visMatch[1] : undefined;
|
|
110
|
+
const memberText = (visMatch ? visMatch[2] : line).trim();
|
|
111
|
+
const member = visibility ? { visibility, text: memberText } : { text: memberText };
|
|
112
|
+
if (memberText.includes('('))
|
|
113
|
+
top.box.methods.push(member);
|
|
114
|
+
else
|
|
115
|
+
top.box.attributes.push(member);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const dirMatch = line.match(/^direction\s+(TD|TB|LR|BT|RL)\b/i);
|
|
119
|
+
if (dirMatch) {
|
|
120
|
+
const requested = dirMatch[1].toUpperCase();
|
|
121
|
+
direction = requested === 'TB' ? 'TD' : requested;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const classMatch = line.match(CLASS_HEADER);
|
|
125
|
+
if (classMatch) {
|
|
126
|
+
const id = stripIdQuotes(classMatch[1] ?? classMatch[2] ?? '');
|
|
127
|
+
if (id.length === 0) {
|
|
128
|
+
warnings.push(`Unsupported line ignored (could not read a class id): ${line}`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const box = getOrCreateClass(id);
|
|
132
|
+
const label = classMatch[3] ?? classMatch[4];
|
|
133
|
+
if (label !== undefined)
|
|
134
|
+
box.label = label.trim();
|
|
135
|
+
if (classMatch[5] === '{')
|
|
136
|
+
stack.push({ kind: 'class', box });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (/^namespace\b/i.test(line)) {
|
|
140
|
+
if (!warnedNamespace) {
|
|
141
|
+
warnings.push('namespace grouping is not yet supported; contained classes are still parsed, the grouping itself is dropped.');
|
|
142
|
+
warnedNamespace = true;
|
|
143
|
+
}
|
|
144
|
+
if (line.endsWith('{'))
|
|
145
|
+
stack.push({ kind: 'other' });
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const { clean, hadQuoted } = stripQuotedSegments(line);
|
|
149
|
+
const relMatch = clean.match(REL_LINE);
|
|
150
|
+
if (relMatch) {
|
|
151
|
+
const fromId = stripIdQuotes(relMatch[1] ?? '');
|
|
152
|
+
const token = relMatch[2] ?? '';
|
|
153
|
+
const toId = stripIdQuotes(relMatch[3] ?? '');
|
|
154
|
+
const info = REL_INFO[token];
|
|
155
|
+
if (fromId.length > 0 && toId.length > 0 && info) {
|
|
156
|
+
getOrCreateClass(fromId);
|
|
157
|
+
getOrCreateClass(toId);
|
|
158
|
+
relationships.push({
|
|
159
|
+
from: fromId,
|
|
160
|
+
to: toId,
|
|
161
|
+
type: info.type,
|
|
162
|
+
markerEnd: info.markerEnd,
|
|
163
|
+
...(relMatch[4] ? { label: relMatch[4].trim() } : {}),
|
|
164
|
+
});
|
|
165
|
+
if (hadQuoted) {
|
|
166
|
+
warnings.push(`Relationship cardinalities are not yet supported, ignored: ${line}`);
|
|
167
|
+
}
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Alternate one-line member syntax outside a `{ }` block:
|
|
172
|
+
// `ClassName : +member text`.
|
|
173
|
+
const standaloneMember = line.match(/^(?:`([^`]+)`|([A-Za-z_$][\w$]*))\s*:\s*(.+)$/);
|
|
174
|
+
if (standaloneMember) {
|
|
175
|
+
const id = stripIdQuotes(standaloneMember[1] ?? standaloneMember[2] ?? '');
|
|
176
|
+
const box = getOrCreateClass(id);
|
|
177
|
+
const rest = (standaloneMember[3] ?? '').trim();
|
|
178
|
+
const visMatch = rest.match(/^([+\-#~])\s*(.+)$/);
|
|
179
|
+
const visibility = visMatch ? visMatch[1] : undefined;
|
|
180
|
+
const memberText = (visMatch ? visMatch[2] : rest).trim();
|
|
181
|
+
const member = visibility ? { visibility, text: memberText } : { text: memberText };
|
|
182
|
+
if (memberText.includes('('))
|
|
183
|
+
box.methods.push(member);
|
|
184
|
+
else
|
|
185
|
+
box.attributes.push(member);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (/^(?:classDef|style|cssClass)\b/i.test(line)) {
|
|
189
|
+
warnings.push(`Styling directives are not yet supported for class diagrams, ignored: ${line}`);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (/^note\b/i.test(line)) {
|
|
193
|
+
warnings.push(`Notes are not yet supported for class diagrams, ignored: ${line}`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (/^<<.*>>$/.test(line)) {
|
|
197
|
+
if (!warnedAnnotation) {
|
|
198
|
+
warnings.push('Class annotations (e.g. <<Interface>>) are not yet rendered, ignored.');
|
|
199
|
+
warnedAnnotation = true;
|
|
200
|
+
}
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
warnings.push(`Unsupported line ignored: ${line}`);
|
|
204
|
+
}
|
|
205
|
+
if (stack.length > 0) {
|
|
206
|
+
warnings.push('One or more class/namespace blocks were not closed with a matching "}".');
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
ast: { direction, classes: [...classes.values()], relationships },
|
|
210
|
+
warnings,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/diagrams/class-diagram/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AASH,8EAA8E;AAC9E,MAAM,iBAAiB,GACrB,2FAA2F,CAAC;AAE9F,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,eAAe,iBAAiB,gCAAgC,CAAC,CAAC;AAE9F,MAAM,QAAQ,GAEV;IACF,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE;IAClD,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;IAChD,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE;IACjD,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;IAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE;IACjD,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;IAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;IAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE;IACjD,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE;IAC9C,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE;IAChD,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;IAChD,MAAM,EAAE,EAAE,IAAI,EAAE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|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOXML translator for a Mermaid `classDiagram` (Family B — reuses Dagre for
|
|
3
|
+
* layout and the same `wps:wsp`-on-`wpc:wpc` shape primitives as
|
|
4
|
+
* `../quadrant/translator.ts`/`../venn/translator.ts`/`../mindmap/translator.ts`,
|
|
5
|
+
* with a node rendering extended to a 3-compartment box (name / attributes /
|
|
6
|
+
* methods) instead of a single label, and relationship lines carrying one of
|
|
7
|
+
* 4 distinct end markers instead of a single arrow style.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `mindmap`'s radial layout, a class diagram's relationships form an
|
|
10
|
+
* arbitrary graph (not a tree), so this reuses the `dagre` package directly
|
|
11
|
+
* — already a dependency via `../../layout/layout.ts` (AGENTS.md rule 6: no
|
|
12
|
+
* new dependency) — rather than `layout.ts`'s own `layout()`, which is typed
|
|
13
|
+
* against the flowchart AST specifically and assumes fixed-size or
|
|
14
|
+
* single-line-label node boxes, neither of which holds for a multi-line
|
|
15
|
+
* compartment box.
|
|
16
|
+
*
|
|
17
|
+
* Relationship lines are straight (box-center to box-center, each end
|
|
18
|
+
* trimmed to its own box border via {@link edgePoint}), not Dagre-routed
|
|
19
|
+
* multi-point polylines like `ooxml-translator.ts`'s flowchart edges — a
|
|
20
|
+
* deliberate v1 simplification (see `parser.ts`'s doc comment for the rest
|
|
21
|
+
* of the v1 scope) that keeps this module from having to re-derive
|
|
22
|
+
* flowchart's considerably more involved connector-routing/magnetic-anchor
|
|
23
|
+
* machinery for a diagram family that is typically far smaller (a handful of
|
|
24
|
+
* classes, not hundreds of flowchart nodes).
|
|
25
|
+
*
|
|
26
|
+
* Marker fidelity is also a deliberate v1 simplification: OOXML's
|
|
27
|
+
* `a:headEnd`/`a:tailEnd` markers are solid-filled with no "hollow outline"
|
|
28
|
+
* variant, so strict UML notation (hollow triangle for inheritance/
|
|
29
|
+
* realization, hollow diamond for aggregation vs. filled for composition)
|
|
30
|
+
* isn't reproducible with this project's one confirmed-working connector
|
|
31
|
+
* primitive. Substituted with the closest distinguishable built-in presets —
|
|
32
|
+
* `oval` standing in for aggregation's hollow diamond, and a smaller
|
|
33
|
+
* `triangle` for association/dependency vs. a larger one for inheritance/
|
|
34
|
+
* realization — so all 8 relationship types still render visually distinct
|
|
35
|
+
* from one another, even if not pixel-identical to strict UML notation.
|
|
36
|
+
*
|
|
37
|
+
* `edgePoint`/`connector`/`rect`/`textBoxLines` live in
|
|
38
|
+
* `../../translator/graph-shapes.ts`, not here — extracted once
|
|
39
|
+
* `../state-diagram/translator.ts` needed the exact same primitives (see
|
|
40
|
+
* that module's own doc comment).
|
|
41
|
+
*/
|
|
42
|
+
import type { ClassDiagram } from './types.js';
|
|
43
|
+
import { type CanvasOptions } from '../../translator/canvas.js';
|
|
44
|
+
/** Translate a parsed class diagram into a self-contained WordprocessingML
|
|
45
|
+
* paragraph. An empty diagram renders a visible note, matching
|
|
46
|
+
* `../venn/translator.ts`'s zero-sets convention — never a silent blank
|
|
47
|
+
* canvas. */
|
|
48
|
+
export declare function translateClassDiagramToOoxml(chart: ClassDiagram, options?: CanvasOptions): string;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOXML translator for a Mermaid `classDiagram` (Family B — reuses Dagre for
|
|
3
|
+
* layout and the same `wps:wsp`-on-`wpc:wpc` shape primitives as
|
|
4
|
+
* `../quadrant/translator.ts`/`../venn/translator.ts`/`../mindmap/translator.ts`,
|
|
5
|
+
* with a node rendering extended to a 3-compartment box (name / attributes /
|
|
6
|
+
* methods) instead of a single label, and relationship lines carrying one of
|
|
7
|
+
* 4 distinct end markers instead of a single arrow style.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `mindmap`'s radial layout, a class diagram's relationships form an
|
|
10
|
+
* arbitrary graph (not a tree), so this reuses the `dagre` package directly
|
|
11
|
+
* — already a dependency via `../../layout/layout.ts` (AGENTS.md rule 6: no
|
|
12
|
+
* new dependency) — rather than `layout.ts`'s own `layout()`, which is typed
|
|
13
|
+
* against the flowchart AST specifically and assumes fixed-size or
|
|
14
|
+
* single-line-label node boxes, neither of which holds for a multi-line
|
|
15
|
+
* compartment box.
|
|
16
|
+
*
|
|
17
|
+
* Relationship lines are straight (box-center to box-center, each end
|
|
18
|
+
* trimmed to its own box border via {@link edgePoint}), not Dagre-routed
|
|
19
|
+
* multi-point polylines like `ooxml-translator.ts`'s flowchart edges — a
|
|
20
|
+
* deliberate v1 simplification (see `parser.ts`'s doc comment for the rest
|
|
21
|
+
* of the v1 scope) that keeps this module from having to re-derive
|
|
22
|
+
* flowchart's considerably more involved connector-routing/magnetic-anchor
|
|
23
|
+
* machinery for a diagram family that is typically far smaller (a handful of
|
|
24
|
+
* classes, not hundreds of flowchart nodes).
|
|
25
|
+
*
|
|
26
|
+
* Marker fidelity is also a deliberate v1 simplification: OOXML's
|
|
27
|
+
* `a:headEnd`/`a:tailEnd` markers are solid-filled with no "hollow outline"
|
|
28
|
+
* variant, so strict UML notation (hollow triangle for inheritance/
|
|
29
|
+
* realization, hollow diamond for aggregation vs. filled for composition)
|
|
30
|
+
* isn't reproducible with this project's one confirmed-working connector
|
|
31
|
+
* primitive. Substituted with the closest distinguishable built-in presets —
|
|
32
|
+
* `oval` standing in for aggregation's hollow diamond, and a smaller
|
|
33
|
+
* `triangle` for association/dependency vs. a larger one for inheritance/
|
|
34
|
+
* realization — so all 8 relationship types still render visually distinct
|
|
35
|
+
* from one another, even if not pixel-identical to strict UML notation.
|
|
36
|
+
*
|
|
37
|
+
* `edgePoint`/`connector`/`rect`/`textBoxLines` live in
|
|
38
|
+
* `../../translator/graph-shapes.ts`, not here — extracted once
|
|
39
|
+
* `../state-diagram/translator.ts` needed the exact same primitives (see
|
|
40
|
+
* that module's own doc comment).
|
|
41
|
+
*/
|
|
42
|
+
import dagre from 'dagre';
|
|
43
|
+
import { estimateTextWidth } from '../../layout/layout.js';
|
|
44
|
+
import { createIdAllocator, scaledExtent, scaledFontSizeHalfPt, scaledLineWidthEmu, wrapDrawingCanvas, } from '../../translator/canvas.js';
|
|
45
|
+
import { connector, edgePoint, rect, scalePt, textBoxLines } from '../../translator/graph-shapes.js';
|
|
46
|
+
const LINE_COLOR = '2F5496';
|
|
47
|
+
const TITLE_FILL = 'D9E2F3';
|
|
48
|
+
const TITLE_FONT_PX = 13;
|
|
49
|
+
const MEMBER_FONT_PX = 10;
|
|
50
|
+
const TITLE_SIZE_HALFPT = 22;
|
|
51
|
+
const MEMBER_SIZE_HALFPT = 18;
|
|
52
|
+
const LABEL_SIZE_HALFPT = 16;
|
|
53
|
+
const TITLE_H = 32;
|
|
54
|
+
const ROW_H = 22;
|
|
55
|
+
const COMPARTMENT_PAD_Y = 6;
|
|
56
|
+
const PAD_X = 10;
|
|
57
|
+
const RANKDIR = {
|
|
58
|
+
TD: 'TB',
|
|
59
|
+
BT: 'BT',
|
|
60
|
+
LR: 'LR',
|
|
61
|
+
RL: 'RL',
|
|
62
|
+
};
|
|
63
|
+
const STYLE_BY_TYPE = {
|
|
64
|
+
inheritance: { dash: 'solid', marker: 'triangle', size: 'lg' },
|
|
65
|
+
realization: { dash: 'dash', marker: 'triangle', size: 'lg' },
|
|
66
|
+
composition: { dash: 'solid', marker: 'diamond', size: 'lg' },
|
|
67
|
+
aggregation: { dash: 'solid', marker: 'oval', size: 'lg' },
|
|
68
|
+
association: { dash: 'solid', marker: 'triangle', size: 'sm' },
|
|
69
|
+
dependency: { dash: 'dash', marker: 'triangle', size: 'sm' },
|
|
70
|
+
link: { dash: 'solid', marker: 'none', size: 'sm' },
|
|
71
|
+
dashedLink: { dash: 'dash', marker: 'none', size: 'sm' },
|
|
72
|
+
};
|
|
73
|
+
function memberDisplay(m) {
|
|
74
|
+
return m.visibility ? `${m.visibility}${m.text}` : m.text;
|
|
75
|
+
}
|
|
76
|
+
function boxSizeFor(box) {
|
|
77
|
+
let width = estimateTextWidth(box.label, TITLE_FONT_PX) + PAD_X * 2 + 16;
|
|
78
|
+
for (const m of [...box.attributes, ...box.methods]) {
|
|
79
|
+
width = Math.max(width, estimateTextWidth(memberDisplay(m), MEMBER_FONT_PX) + PAD_X * 2);
|
|
80
|
+
}
|
|
81
|
+
width = Math.max(90, width);
|
|
82
|
+
const attrH = box.attributes.length > 0 ? box.attributes.length * ROW_H + COMPARTMENT_PAD_Y : 0;
|
|
83
|
+
const methodH = box.methods.length > 0 ? box.methods.length * ROW_H + COMPARTMENT_PAD_Y : 0;
|
|
84
|
+
return { width, height: TITLE_H + attrH + methodH, titleH: TITLE_H, attrH, methodH };
|
|
85
|
+
}
|
|
86
|
+
function classBoxShapes(nextId, box, size, x, y, s) {
|
|
87
|
+
const parts = [];
|
|
88
|
+
const bx = scalePt(x, s);
|
|
89
|
+
const by = scalePt(y, s);
|
|
90
|
+
const w = scalePt(size.width, s);
|
|
91
|
+
const titleH = scalePt(size.titleH, s);
|
|
92
|
+
const attrH = scalePt(size.attrH, s);
|
|
93
|
+
const methodH = scalePt(size.methodH, s);
|
|
94
|
+
const totalH = titleH + attrH + methodH;
|
|
95
|
+
const borderW = scaledLineWidthEmu(9525, s);
|
|
96
|
+
parts.push(rect(nextId(), bx, by, w, totalH, 'FFFFFF', LINE_COLOR, box.label));
|
|
97
|
+
parts.push(rect(nextId(), bx, by, w, titleH, TITLE_FILL, undefined, `${box.label} title`));
|
|
98
|
+
let dividerY = by + titleH;
|
|
99
|
+
if (attrH > 0) {
|
|
100
|
+
parts.push(rect(nextId(), bx, dividerY - Math.round(borderW / 2), w, borderW, LINE_COLOR, undefined, 'Divider'));
|
|
101
|
+
dividerY += attrH;
|
|
102
|
+
}
|
|
103
|
+
if (methodH > 0) {
|
|
104
|
+
parts.push(rect(nextId(), bx, dividerY - Math.round(borderW / 2), w, borderW, LINE_COLOR, undefined, 'Divider'));
|
|
105
|
+
}
|
|
106
|
+
parts.push(textBoxLines(nextId(), bx, by, w, titleH, [box.label], scaledFontSizeHalfPt(TITLE_SIZE_HALFPT, s), { bold: true, align: 'ctr' }));
|
|
107
|
+
const padX = scalePt(PAD_X, s);
|
|
108
|
+
if (attrH > 0) {
|
|
109
|
+
parts.push(textBoxLines(nextId(), bx + padX, by + titleH, w - 2 * padX, attrH, box.attributes.map(memberDisplay), scaledFontSizeHalfPt(MEMBER_SIZE_HALFPT, s)));
|
|
110
|
+
}
|
|
111
|
+
if (methodH > 0) {
|
|
112
|
+
parts.push(textBoxLines(nextId(), bx + padX, by + titleH + attrH, w - 2 * padX, methodH, box.methods.map(memberDisplay), scaledFontSizeHalfPt(MEMBER_SIZE_HALFPT, s)));
|
|
113
|
+
}
|
|
114
|
+
return parts;
|
|
115
|
+
}
|
|
116
|
+
/** Translate a parsed class diagram into a self-contained WordprocessingML
|
|
117
|
+
* paragraph. An empty diagram renders a visible note, matching
|
|
118
|
+
* `../venn/translator.ts`'s zero-sets convention — never a silent blank
|
|
119
|
+
* canvas. */
|
|
120
|
+
export function translateClassDiagramToOoxml(chart, options = {}) {
|
|
121
|
+
if (chart.classes.length === 0) {
|
|
122
|
+
return [
|
|
123
|
+
'<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">',
|
|
124
|
+
' <w:pPr><w:spacing w:before="0" w:after="120"/></w:pPr>',
|
|
125
|
+
' <w:r>',
|
|
126
|
+
' <w:rPr><w:i/><w:color w:val="808080"/><w:sz w:val="18"/></w:rPr>',
|
|
127
|
+
' <w:t xml:space="preserve">This class diagram has no content to render.</w:t>',
|
|
128
|
+
' </w:r>',
|
|
129
|
+
'</w:p>',
|
|
130
|
+
].join('\n');
|
|
131
|
+
}
|
|
132
|
+
const sizes = new Map();
|
|
133
|
+
const g = new dagre.graphlib.Graph();
|
|
134
|
+
g.setGraph({ rankdir: RANKDIR[chart.direction], nodesep: 50, ranksep: 70, marginx: 0, marginy: 0 });
|
|
135
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
136
|
+
for (const box of chart.classes) {
|
|
137
|
+
const size = boxSizeFor(box);
|
|
138
|
+
sizes.set(box.id, size);
|
|
139
|
+
g.setNode(box.id, { width: size.width, height: size.height });
|
|
140
|
+
}
|
|
141
|
+
for (const rel of chart.relationships) {
|
|
142
|
+
if (g.hasNode(rel.from) && g.hasNode(rel.to))
|
|
143
|
+
g.setEdge(rel.from, rel.to);
|
|
144
|
+
}
|
|
145
|
+
dagre.layout(g);
|
|
146
|
+
let minX = Infinity;
|
|
147
|
+
let maxX = -Infinity;
|
|
148
|
+
let minY = Infinity;
|
|
149
|
+
let maxY = -Infinity;
|
|
150
|
+
for (const box of chart.classes) {
|
|
151
|
+
const n = g.node(box.id);
|
|
152
|
+
const size = sizes.get(box.id);
|
|
153
|
+
minX = Math.min(minX, n.x - size.width / 2);
|
|
154
|
+
maxX = Math.max(maxX, n.x + size.width / 2);
|
|
155
|
+
minY = Math.min(minY, n.y - size.height / 2);
|
|
156
|
+
maxY = Math.max(maxY, n.y + size.height / 2);
|
|
157
|
+
}
|
|
158
|
+
const PAD = 24;
|
|
159
|
+
const canvasW = maxX - minX + 2 * PAD;
|
|
160
|
+
const canvasH = maxY - minY + 2 * PAD;
|
|
161
|
+
const dx = -minX + PAD;
|
|
162
|
+
const dy = -minY + PAD;
|
|
163
|
+
const { scale: s } = scaledExtent(canvasW, canvasH, options);
|
|
164
|
+
const nextId = createIdAllocator();
|
|
165
|
+
const parts = [];
|
|
166
|
+
// Relationships first (z-order = emission order), so class boxes always
|
|
167
|
+
// render on top of the lines feeding into them.
|
|
168
|
+
for (const rel of chart.relationships) {
|
|
169
|
+
const nFrom = g.node(rel.from);
|
|
170
|
+
const nTo = g.node(rel.to);
|
|
171
|
+
if (!nFrom || !nTo)
|
|
172
|
+
continue;
|
|
173
|
+
const sizeFrom = sizes.get(rel.from);
|
|
174
|
+
const sizeTo = sizes.get(rel.to);
|
|
175
|
+
const p1 = edgePoint(nFrom.x, nFrom.y, sizeFrom.width / 2, sizeFrom.height / 2, nTo.x, nTo.y);
|
|
176
|
+
const p2 = edgePoint(nTo.x, nTo.y, sizeTo.width / 2, sizeTo.height / 2, nFrom.x, nFrom.y);
|
|
177
|
+
const style = STYLE_BY_TYPE[rel.type];
|
|
178
|
+
const headMarker = rel.markerEnd === 'from' ? style.marker : 'none';
|
|
179
|
+
const tailMarker = rel.markerEnd === 'to' ? style.marker : 'none';
|
|
180
|
+
parts.push(connector(nextId(), scalePt(p1.x + dx, s), scalePt(p1.y + dy, s), scalePt(p2.x + dx, s), scalePt(p2.y + dy, s), LINE_COLOR, scaledLineWidthEmu(9525, s), style.dash, headMarker, style.size, tailMarker, style.size));
|
|
181
|
+
if (rel.label) {
|
|
182
|
+
const midX = (p1.x + p2.x) / 2;
|
|
183
|
+
const midY = (p1.y + p2.y) / 2;
|
|
184
|
+
const labelWidth = estimateTextWidth(rel.label, 8) + 12;
|
|
185
|
+
parts.push(textBoxLines(nextId(), scalePt(midX + dx - labelWidth / 2, s), scalePt(midY + dy - 10, s), scalePt(labelWidth, s), scalePt(20, s), [rel.label], scaledFontSizeHalfPt(LABEL_SIZE_HALFPT, s), { align: 'ctr' }));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
for (const box of chart.classes) {
|
|
189
|
+
const n = g.node(box.id);
|
|
190
|
+
const size = sizes.get(box.id);
|
|
191
|
+
parts.push(...classBoxShapes(nextId, box, size, n.x - size.width / 2 + dx, n.y - size.height / 2 + dy, s));
|
|
192
|
+
}
|
|
193
|
+
const content = parts.join('\n');
|
|
194
|
+
const docPrId = nextId();
|
|
195
|
+
return wrapDrawingCanvas(content, canvasW, canvasH, docPrId, 'Class diagram', options);
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=translator.js.map
|