@diagrammo/dgmo 0.2.8 → 0.2.10
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 +29 -1
- package/dist/cli.cjs +105 -105
- package/dist/index.cjs +6457 -6137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +6474 -6158
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chart.ts +11 -0
- package/src/cli.ts +14 -34
- package/src/d3.ts +160 -15
- package/src/echarts.ts +56 -2
- package/src/graph/flowchart-parser.ts +1 -0
- package/src/graph/flowchart-renderer.ts +15 -4
- package/src/graph/types.ts +1 -0
- package/src/index.ts +7 -0
- package/src/render.ts +68 -0
- package/src/sequence/parser.ts +3 -0
- package/src/sequence/renderer.ts +311 -127
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { EChartsOption } from 'echarts';
|
|
2
2
|
import * as d3Scale from 'd3-scale';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Render DGMO source to an SVG string.
|
|
6
|
+
*
|
|
7
|
+
* Automatically detects the chart type, selects the appropriate renderer,
|
|
8
|
+
* and returns a complete SVG document string.
|
|
9
|
+
*
|
|
10
|
+
* @param content - DGMO source text
|
|
11
|
+
* @param options - Optional theme and palette settings
|
|
12
|
+
* @returns SVG string, or empty string on error
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { render } from '@diagrammo/dgmo';
|
|
17
|
+
*
|
|
18
|
+
* const svg = await render(`chart: pie
|
|
19
|
+
* title: Languages
|
|
20
|
+
* TypeScript: 45
|
|
21
|
+
* Python: 30
|
|
22
|
+
* Rust: 25`);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function render(content: string, options?: {
|
|
26
|
+
theme?: 'light' | 'dark' | 'transparent';
|
|
27
|
+
palette?: string;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
|
|
4
30
|
/**
|
|
5
31
|
* Framework identifiers used by the .dgmo router.
|
|
6
32
|
* Maps to the existing preview components and export paths.
|
|
@@ -171,6 +197,7 @@ interface ChartDataPoint {
|
|
|
171
197
|
interface ParsedChart {
|
|
172
198
|
type: ChartType;
|
|
173
199
|
title?: string;
|
|
200
|
+
titleLineNumber?: number;
|
|
174
201
|
series?: string;
|
|
175
202
|
xlabel?: string;
|
|
176
203
|
ylabel?: string;
|
|
@@ -179,6 +206,7 @@ interface ParsedChart {
|
|
|
179
206
|
orientation?: 'horizontal' | 'vertical';
|
|
180
207
|
color?: string;
|
|
181
208
|
label?: string;
|
|
209
|
+
labels?: 'name' | 'value' | 'percent' | 'full';
|
|
182
210
|
data: ChartDataPoint[];
|
|
183
211
|
error?: string;
|
|
184
212
|
}
|
|
@@ -235,6 +263,7 @@ interface ParsedHeatmapRow {
|
|
|
235
263
|
interface ParsedEChart {
|
|
236
264
|
type: EChartsChartType;
|
|
237
265
|
title?: string;
|
|
266
|
+
titleLineNumber?: number;
|
|
238
267
|
series?: string;
|
|
239
268
|
seriesNames?: string[];
|
|
240
269
|
seriesNameColors?: (string | undefined)[];
|
|
@@ -384,6 +413,7 @@ interface D3ExportDimensions {
|
|
|
384
413
|
interface ParsedD3 {
|
|
385
414
|
type: D3ChartType | null;
|
|
386
415
|
title: string | null;
|
|
416
|
+
titleLineNumber: number | null;
|
|
387
417
|
orientation: 'horizontal' | 'vertical';
|
|
388
418
|
periods: string[];
|
|
389
419
|
data: D3DataItem[];
|
|
@@ -565,6 +595,7 @@ interface SequenceGroup {
|
|
|
565
595
|
*/
|
|
566
596
|
interface ParsedSequenceDgmo {
|
|
567
597
|
title: string | null;
|
|
598
|
+
titleLineNumber: number | null;
|
|
568
599
|
participants: SequenceParticipant[];
|
|
569
600
|
messages: SequenceMessage[];
|
|
570
601
|
elements: SequenceElement[];
|
|
@@ -661,6 +692,7 @@ interface GraphGroup {
|
|
|
661
692
|
interface ParsedGraph {
|
|
662
693
|
type: 'flowchart';
|
|
663
694
|
title?: string;
|
|
695
|
+
titleLineNumber?: number;
|
|
664
696
|
direction: GraphDirection;
|
|
665
697
|
nodes: GraphNode[];
|
|
666
698
|
edges: GraphEdge[];
|
|
@@ -729,6 +761,7 @@ interface SectionMessageGroup {
|
|
|
729
761
|
}
|
|
730
762
|
interface SequenceRenderOptions {
|
|
731
763
|
collapsedSections?: Set<number>;
|
|
764
|
+
expandedNoteLines?: Set<number>;
|
|
732
765
|
exportWidth?: number;
|
|
733
766
|
}
|
|
734
767
|
/**
|
|
@@ -777,6 +810,12 @@ declare function applyGroupOrdering(participants: SequenceParticipant[], groups:
|
|
|
777
810
|
* Render a sequence diagram into the given container element.
|
|
778
811
|
*/
|
|
779
812
|
declare function renderSequenceDiagram(container: HTMLDivElement, parsed: ParsedSequenceDgmo, palette: PaletteColors, isDark: boolean, _onNavigateToLine?: (line: number) => void, options?: SequenceRenderOptions): void;
|
|
813
|
+
/**
|
|
814
|
+
* Build a mapping from each note's lineNumber to the lineNumber of its
|
|
815
|
+
* associated message (the last message before the note in document order).
|
|
816
|
+
* Used by the app to expand notes when cursor is on the associated message.
|
|
817
|
+
*/
|
|
818
|
+
declare function buildNoteMessageMap(elements: SequenceElement[]): Map<number, number>;
|
|
780
819
|
|
|
781
820
|
/** Complete 16-entry Nord palette. */
|
|
782
821
|
declare const nord: {
|
|
@@ -811,4 +850,4 @@ declare function resolveColor(color: string, palette?: {
|
|
|
811
850
|
/** @deprecated Use getSeriesColors(palette) from '@/lib/palettes' instead. */
|
|
812
851
|
declare const seriesColors: string[];
|
|
813
852
|
|
|
814
|
-
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type ElseIfBranch, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedGraph, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildEChartsOption, buildEChartsOptionFromChart, buildMermaidQuadrant, buildMermaidThemeVars, buildRenderSequence, buildThemeCSS, catppuccinPalette, colorNames, computeActivations, computeTimeTicks, contrastText, formatDateLabel, getAvailablePalettes, getDgmoFramework, getPalette, getSeriesColors, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, isSequenceBlock, isSequenceNote, isValidHex, layoutGraph, looksLikeFlowchart, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseFlowchart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderFlowchart, renderFlowchartForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|
|
853
|
+
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type ElseIfBranch, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedGraph, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildEChartsOption, buildEChartsOptionFromChart, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildThemeCSS, catppuccinPalette, colorNames, computeActivations, computeTimeTicks, contrastText, formatDateLabel, getAvailablePalettes, getDgmoFramework, getPalette, getSeriesColors, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, isSequenceBlock, isSequenceNote, isValidHex, layoutGraph, looksLikeFlowchart, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseFlowchart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, render, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderFlowchart, renderFlowchartForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { EChartsOption } from 'echarts';
|
|
2
2
|
import * as d3Scale from 'd3-scale';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Render DGMO source to an SVG string.
|
|
6
|
+
*
|
|
7
|
+
* Automatically detects the chart type, selects the appropriate renderer,
|
|
8
|
+
* and returns a complete SVG document string.
|
|
9
|
+
*
|
|
10
|
+
* @param content - DGMO source text
|
|
11
|
+
* @param options - Optional theme and palette settings
|
|
12
|
+
* @returns SVG string, or empty string on error
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { render } from '@diagrammo/dgmo';
|
|
17
|
+
*
|
|
18
|
+
* const svg = await render(`chart: pie
|
|
19
|
+
* title: Languages
|
|
20
|
+
* TypeScript: 45
|
|
21
|
+
* Python: 30
|
|
22
|
+
* Rust: 25`);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function render(content: string, options?: {
|
|
26
|
+
theme?: 'light' | 'dark' | 'transparent';
|
|
27
|
+
palette?: string;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
|
|
4
30
|
/**
|
|
5
31
|
* Framework identifiers used by the .dgmo router.
|
|
6
32
|
* Maps to the existing preview components and export paths.
|
|
@@ -171,6 +197,7 @@ interface ChartDataPoint {
|
|
|
171
197
|
interface ParsedChart {
|
|
172
198
|
type: ChartType;
|
|
173
199
|
title?: string;
|
|
200
|
+
titleLineNumber?: number;
|
|
174
201
|
series?: string;
|
|
175
202
|
xlabel?: string;
|
|
176
203
|
ylabel?: string;
|
|
@@ -179,6 +206,7 @@ interface ParsedChart {
|
|
|
179
206
|
orientation?: 'horizontal' | 'vertical';
|
|
180
207
|
color?: string;
|
|
181
208
|
label?: string;
|
|
209
|
+
labels?: 'name' | 'value' | 'percent' | 'full';
|
|
182
210
|
data: ChartDataPoint[];
|
|
183
211
|
error?: string;
|
|
184
212
|
}
|
|
@@ -235,6 +263,7 @@ interface ParsedHeatmapRow {
|
|
|
235
263
|
interface ParsedEChart {
|
|
236
264
|
type: EChartsChartType;
|
|
237
265
|
title?: string;
|
|
266
|
+
titleLineNumber?: number;
|
|
238
267
|
series?: string;
|
|
239
268
|
seriesNames?: string[];
|
|
240
269
|
seriesNameColors?: (string | undefined)[];
|
|
@@ -384,6 +413,7 @@ interface D3ExportDimensions {
|
|
|
384
413
|
interface ParsedD3 {
|
|
385
414
|
type: D3ChartType | null;
|
|
386
415
|
title: string | null;
|
|
416
|
+
titleLineNumber: number | null;
|
|
387
417
|
orientation: 'horizontal' | 'vertical';
|
|
388
418
|
periods: string[];
|
|
389
419
|
data: D3DataItem[];
|
|
@@ -565,6 +595,7 @@ interface SequenceGroup {
|
|
|
565
595
|
*/
|
|
566
596
|
interface ParsedSequenceDgmo {
|
|
567
597
|
title: string | null;
|
|
598
|
+
titleLineNumber: number | null;
|
|
568
599
|
participants: SequenceParticipant[];
|
|
569
600
|
messages: SequenceMessage[];
|
|
570
601
|
elements: SequenceElement[];
|
|
@@ -661,6 +692,7 @@ interface GraphGroup {
|
|
|
661
692
|
interface ParsedGraph {
|
|
662
693
|
type: 'flowchart';
|
|
663
694
|
title?: string;
|
|
695
|
+
titleLineNumber?: number;
|
|
664
696
|
direction: GraphDirection;
|
|
665
697
|
nodes: GraphNode[];
|
|
666
698
|
edges: GraphEdge[];
|
|
@@ -729,6 +761,7 @@ interface SectionMessageGroup {
|
|
|
729
761
|
}
|
|
730
762
|
interface SequenceRenderOptions {
|
|
731
763
|
collapsedSections?: Set<number>;
|
|
764
|
+
expandedNoteLines?: Set<number>;
|
|
732
765
|
exportWidth?: number;
|
|
733
766
|
}
|
|
734
767
|
/**
|
|
@@ -777,6 +810,12 @@ declare function applyGroupOrdering(participants: SequenceParticipant[], groups:
|
|
|
777
810
|
* Render a sequence diagram into the given container element.
|
|
778
811
|
*/
|
|
779
812
|
declare function renderSequenceDiagram(container: HTMLDivElement, parsed: ParsedSequenceDgmo, palette: PaletteColors, isDark: boolean, _onNavigateToLine?: (line: number) => void, options?: SequenceRenderOptions): void;
|
|
813
|
+
/**
|
|
814
|
+
* Build a mapping from each note's lineNumber to the lineNumber of its
|
|
815
|
+
* associated message (the last message before the note in document order).
|
|
816
|
+
* Used by the app to expand notes when cursor is on the associated message.
|
|
817
|
+
*/
|
|
818
|
+
declare function buildNoteMessageMap(elements: SequenceElement[]): Map<number, number>;
|
|
780
819
|
|
|
781
820
|
/** Complete 16-entry Nord palette. */
|
|
782
821
|
declare const nord: {
|
|
@@ -811,4 +850,4 @@ declare function resolveColor(color: string, palette?: {
|
|
|
811
850
|
/** @deprecated Use getSeriesColors(palette) from '@/lib/palettes' instead. */
|
|
812
851
|
declare const seriesColors: string[];
|
|
813
852
|
|
|
814
|
-
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type ElseIfBranch, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedGraph, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildEChartsOption, buildEChartsOptionFromChart, buildMermaidQuadrant, buildMermaidThemeVars, buildRenderSequence, buildThemeCSS, catppuccinPalette, colorNames, computeActivations, computeTimeTicks, contrastText, formatDateLabel, getAvailablePalettes, getDgmoFramework, getPalette, getSeriesColors, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, isSequenceBlock, isSequenceNote, isValidHex, layoutGraph, looksLikeFlowchart, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseFlowchart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderFlowchart, renderFlowchartForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|
|
853
|
+
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type ElseIfBranch, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedGraph, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildEChartsOption, buildEChartsOptionFromChart, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildThemeCSS, catppuccinPalette, colorNames, computeActivations, computeTimeTicks, contrastText, formatDateLabel, getAvailablePalettes, getDgmoFramework, getPalette, getSeriesColors, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, isSequenceBlock, isSequenceNote, isValidHex, layoutGraph, looksLikeFlowchart, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseFlowchart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, render, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderFlowchart, renderFlowchartForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|