@diagrammo/dgmo 0.3.1 → 0.4.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 +11 -14
- package/dist/cli.cjs +150 -151
- package/dist/index.cjs +460 -901
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +459 -901
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +18 -19
- package/package.json +1 -1
- package/src/chart.ts +8 -39
- package/src/cli.ts +6 -6
- package/src/d3.ts +299 -715
- package/src/dgmo-router.ts +21 -42
- package/src/echarts.ts +134 -241
- package/src/index.ts +1 -0
- package/src/sequence/parser.ts +55 -106
- package/src/sequence/renderer.ts +4 -60
- package/src/utils/arrows.ts +43 -18
- package/src/utils/parsing.ts +43 -0
package/src/dgmo-router.ts
CHANGED
|
@@ -99,8 +99,8 @@ export function parseDgmoChartType(content: string): string | null {
|
|
|
99
99
|
return null;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
const STANDARD_CHART_TYPES = new Set([
|
|
102
|
+
/** Standard chart types parsed by parseChart (then rendered via ECharts). */
|
|
103
|
+
export const STANDARD_CHART_TYPES = new Set([
|
|
104
104
|
'bar', 'line', 'multi-line', 'area', 'pie', 'doughnut',
|
|
105
105
|
'radar', 'polar-area', 'bar-stacked',
|
|
106
106
|
]);
|
|
@@ -110,6 +110,18 @@ const ECHART_TYPES = new Set([
|
|
|
110
110
|
'scatter', 'sankey', 'chord', 'function', 'heatmap', 'funnel',
|
|
111
111
|
]);
|
|
112
112
|
|
|
113
|
+
/** Map chart type strings to their parse function (content → { diagnostics }). */
|
|
114
|
+
const PARSE_DISPATCH = new Map<string, (content: string) => { diagnostics: DgmoError[] }>([
|
|
115
|
+
['sequence', (c) => parseSequenceDgmo(c)],
|
|
116
|
+
['flowchart', (c) => parseFlowchart(c)],
|
|
117
|
+
['class', (c) => parseClassDiagram(c)],
|
|
118
|
+
['er', (c) => parseERDiagram(c)],
|
|
119
|
+
['org', (c) => parseOrg(c)],
|
|
120
|
+
['kanban', (c) => parseKanban(c)],
|
|
121
|
+
['c4', (c) => parseC4(c)],
|
|
122
|
+
['initiative-status', (c) => parseInitiativeStatus(c)],
|
|
123
|
+
]);
|
|
124
|
+
|
|
113
125
|
/**
|
|
114
126
|
* Parse DGMO content and return diagnostics without rendering.
|
|
115
127
|
* Useful for the CLI and editor to surface all errors before attempting render.
|
|
@@ -119,52 +131,19 @@ export function parseDgmo(content: string): { diagnostics: DgmoError[] } {
|
|
|
119
131
|
|
|
120
132
|
if (!chartType) {
|
|
121
133
|
// No chart type detected — try D3 parser as fallback (it handles missing chart: line)
|
|
122
|
-
|
|
123
|
-
return { diagnostics: parsed.diagnostics };
|
|
134
|
+
return { diagnostics: parseD3(content).diagnostics };
|
|
124
135
|
}
|
|
125
136
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
if (chartType === 'flowchart') {
|
|
131
|
-
const parsed = parseFlowchart(content);
|
|
132
|
-
return { diagnostics: parsed.diagnostics };
|
|
133
|
-
}
|
|
134
|
-
if (chartType === 'class') {
|
|
135
|
-
const parsed = parseClassDiagram(content);
|
|
136
|
-
return { diagnostics: parsed.diagnostics };
|
|
137
|
-
}
|
|
138
|
-
if (chartType === 'er') {
|
|
139
|
-
const parsed = parseERDiagram(content);
|
|
140
|
-
return { diagnostics: parsed.diagnostics };
|
|
141
|
-
}
|
|
142
|
-
if (chartType === 'org') {
|
|
143
|
-
const parsed = parseOrg(content);
|
|
144
|
-
return { diagnostics: parsed.diagnostics };
|
|
145
|
-
}
|
|
146
|
-
if (chartType === 'kanban') {
|
|
147
|
-
const parsed = parseKanban(content);
|
|
148
|
-
return { diagnostics: parsed.diagnostics };
|
|
149
|
-
}
|
|
150
|
-
if (chartType === 'c4') {
|
|
151
|
-
const parsed = parseC4(content);
|
|
152
|
-
return { diagnostics: parsed.diagnostics };
|
|
153
|
-
}
|
|
154
|
-
if (chartType === 'initiative-status') {
|
|
155
|
-
const parsed = parseInitiativeStatus(content);
|
|
156
|
-
return { diagnostics: parsed.diagnostics };
|
|
157
|
-
}
|
|
137
|
+
const directParser = PARSE_DISPATCH.get(chartType);
|
|
138
|
+
if (directParser) return { diagnostics: directParser(content).diagnostics };
|
|
139
|
+
|
|
158
140
|
if (STANDARD_CHART_TYPES.has(chartType)) {
|
|
159
|
-
|
|
160
|
-
return { diagnostics: parsed.diagnostics };
|
|
141
|
+
return { diagnostics: parseChart(content).diagnostics };
|
|
161
142
|
}
|
|
162
143
|
if (ECHART_TYPES.has(chartType)) {
|
|
163
|
-
|
|
164
|
-
return { diagnostics: parsed.diagnostics };
|
|
144
|
+
return { diagnostics: parseEChart(content).diagnostics };
|
|
165
145
|
}
|
|
166
146
|
|
|
167
147
|
// D3 types (slope, wordcloud, arc, timeline, venn, quadrant)
|
|
168
|
-
|
|
169
|
-
return { diagnostics: parsed.diagnostics };
|
|
148
|
+
return { diagnostics: parseD3(content).diagnostics };
|
|
170
149
|
}
|