@diagrammo/dgmo 0.2.6 → 0.2.8
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 +213 -57
- package/dist/cli.cjs +91 -85
- package/dist/index.cjs +1362 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -2
- package/dist/index.d.ts +108 -2
- package/dist/index.js +1357 -193
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/d3.ts +59 -1
- package/src/dgmo-router.ts +5 -1
- package/src/echarts.ts +2 -2
- package/src/graph/flowchart-parser.ts +499 -0
- package/src/graph/flowchart-renderer.ts +503 -0
- package/src/graph/layout.ts +222 -0
- package/src/graph/types.ts +44 -0
- package/src/index.ts +24 -0
- package/src/sequence/parser.ts +221 -37
- package/src/sequence/renderer.ts +342 -16
package/dist/index.d.cts
CHANGED
|
@@ -515,12 +515,17 @@ interface SequenceMessage {
|
|
|
515
515
|
/**
|
|
516
516
|
* A conditional or loop block in the sequence diagram.
|
|
517
517
|
*/
|
|
518
|
+
interface ElseIfBranch {
|
|
519
|
+
label: string;
|
|
520
|
+
children: SequenceElement[];
|
|
521
|
+
}
|
|
518
522
|
interface SequenceBlock {
|
|
519
523
|
kind: 'block';
|
|
520
524
|
type: 'if' | 'loop' | 'parallel';
|
|
521
525
|
label: string;
|
|
522
526
|
children: SequenceElement[];
|
|
523
527
|
elseChildren: SequenceElement[];
|
|
528
|
+
elseIfBranches?: ElseIfBranch[];
|
|
524
529
|
lineNumber: number;
|
|
525
530
|
}
|
|
526
531
|
/**
|
|
@@ -532,8 +537,20 @@ interface SequenceSection {
|
|
|
532
537
|
color?: string;
|
|
533
538
|
lineNumber: number;
|
|
534
539
|
}
|
|
535
|
-
|
|
540
|
+
/**
|
|
541
|
+
* An annotation attached to a message, rendered as a folded-corner box.
|
|
542
|
+
*/
|
|
543
|
+
interface SequenceNote {
|
|
544
|
+
kind: 'note';
|
|
545
|
+
text: string;
|
|
546
|
+
position: 'right' | 'left';
|
|
547
|
+
participantId: string;
|
|
548
|
+
lineNumber: number;
|
|
549
|
+
endLineNumber: number;
|
|
550
|
+
}
|
|
551
|
+
type SequenceElement = SequenceMessage | SequenceBlock | SequenceSection | SequenceNote;
|
|
536
552
|
declare function isSequenceBlock(el: SequenceElement): el is SequenceBlock;
|
|
553
|
+
declare function isSequenceNote(el: SequenceElement): el is SequenceNote;
|
|
537
554
|
/**
|
|
538
555
|
* A named group of participants rendered as a labeled box.
|
|
539
556
|
*/
|
|
@@ -617,6 +634,95 @@ declare function buildMermaidQuadrant(parsed: ParsedQuadrant, options?: {
|
|
|
617
634
|
mutedTextColor?: string;
|
|
618
635
|
}): string;
|
|
619
636
|
|
|
637
|
+
type GraphShape = 'terminal' | 'process' | 'decision' | 'io' | 'subroutine' | 'document';
|
|
638
|
+
type GraphDirection = 'TB' | 'LR';
|
|
639
|
+
interface GraphNode {
|
|
640
|
+
id: string;
|
|
641
|
+
label: string;
|
|
642
|
+
shape: GraphShape;
|
|
643
|
+
color?: string;
|
|
644
|
+
group?: string;
|
|
645
|
+
lineNumber: number;
|
|
646
|
+
}
|
|
647
|
+
interface GraphEdge {
|
|
648
|
+
source: string;
|
|
649
|
+
target: string;
|
|
650
|
+
label?: string;
|
|
651
|
+
color?: string;
|
|
652
|
+
lineNumber: number;
|
|
653
|
+
}
|
|
654
|
+
interface GraphGroup {
|
|
655
|
+
id: string;
|
|
656
|
+
label: string;
|
|
657
|
+
color?: string;
|
|
658
|
+
nodeIds: string[];
|
|
659
|
+
lineNumber: number;
|
|
660
|
+
}
|
|
661
|
+
interface ParsedGraph {
|
|
662
|
+
type: 'flowchart';
|
|
663
|
+
title?: string;
|
|
664
|
+
direction: GraphDirection;
|
|
665
|
+
nodes: GraphNode[];
|
|
666
|
+
edges: GraphEdge[];
|
|
667
|
+
groups?: GraphGroup[];
|
|
668
|
+
error?: string;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
declare function parseFlowchart(content: string, palette?: PaletteColors): ParsedGraph;
|
|
672
|
+
/**
|
|
673
|
+
* Detect if content looks like a flowchart (without explicit `chart: flowchart` header).
|
|
674
|
+
* Checks for shape delimiters combined with `->` arrows.
|
|
675
|
+
* Avoids false-positives on sequence diagrams (which use bare names with `->`)
|
|
676
|
+
*/
|
|
677
|
+
declare function looksLikeFlowchart(content: string): boolean;
|
|
678
|
+
|
|
679
|
+
interface LayoutNode {
|
|
680
|
+
id: string;
|
|
681
|
+
label: string;
|
|
682
|
+
shape: GraphShape;
|
|
683
|
+
color?: string;
|
|
684
|
+
group?: string;
|
|
685
|
+
lineNumber: number;
|
|
686
|
+
x: number;
|
|
687
|
+
y: number;
|
|
688
|
+
width: number;
|
|
689
|
+
height: number;
|
|
690
|
+
}
|
|
691
|
+
interface LayoutEdge {
|
|
692
|
+
source: string;
|
|
693
|
+
target: string;
|
|
694
|
+
points: {
|
|
695
|
+
x: number;
|
|
696
|
+
y: number;
|
|
697
|
+
}[];
|
|
698
|
+
label?: string;
|
|
699
|
+
color?: string;
|
|
700
|
+
lineNumber: number;
|
|
701
|
+
}
|
|
702
|
+
interface LayoutGroup {
|
|
703
|
+
id: string;
|
|
704
|
+
label: string;
|
|
705
|
+
color?: string;
|
|
706
|
+
x: number;
|
|
707
|
+
y: number;
|
|
708
|
+
width: number;
|
|
709
|
+
height: number;
|
|
710
|
+
}
|
|
711
|
+
interface LayoutResult {
|
|
712
|
+
nodes: LayoutNode[];
|
|
713
|
+
edges: LayoutEdge[];
|
|
714
|
+
groups: LayoutGroup[];
|
|
715
|
+
width: number;
|
|
716
|
+
height: number;
|
|
717
|
+
}
|
|
718
|
+
declare function layoutGraph(graph: ParsedGraph): LayoutResult;
|
|
719
|
+
|
|
720
|
+
declare function renderFlowchart(container: HTMLDivElement, graph: ParsedGraph, layout: LayoutResult, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: {
|
|
721
|
+
width?: number;
|
|
722
|
+
height?: number;
|
|
723
|
+
}): void;
|
|
724
|
+
declare function renderFlowchartForExport(content: string, theme: 'light' | 'dark' | 'transparent', palette: PaletteColors): string;
|
|
725
|
+
|
|
620
726
|
interface SectionMessageGroup {
|
|
621
727
|
section: SequenceSection;
|
|
622
728
|
messageIndices: number[];
|
|
@@ -705,4 +811,4 @@ declare function resolveColor(color: string, palette?: {
|
|
|
705
811
|
/** @deprecated Use getSeriesColors(palette) from '@/lib/palettes' instead. */
|
|
706
812
|
declare const seriesColors: string[];
|
|
707
813
|
|
|
708
|
-
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, 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, isValidHex, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -515,12 +515,17 @@ interface SequenceMessage {
|
|
|
515
515
|
/**
|
|
516
516
|
* A conditional or loop block in the sequence diagram.
|
|
517
517
|
*/
|
|
518
|
+
interface ElseIfBranch {
|
|
519
|
+
label: string;
|
|
520
|
+
children: SequenceElement[];
|
|
521
|
+
}
|
|
518
522
|
interface SequenceBlock {
|
|
519
523
|
kind: 'block';
|
|
520
524
|
type: 'if' | 'loop' | 'parallel';
|
|
521
525
|
label: string;
|
|
522
526
|
children: SequenceElement[];
|
|
523
527
|
elseChildren: SequenceElement[];
|
|
528
|
+
elseIfBranches?: ElseIfBranch[];
|
|
524
529
|
lineNumber: number;
|
|
525
530
|
}
|
|
526
531
|
/**
|
|
@@ -532,8 +537,20 @@ interface SequenceSection {
|
|
|
532
537
|
color?: string;
|
|
533
538
|
lineNumber: number;
|
|
534
539
|
}
|
|
535
|
-
|
|
540
|
+
/**
|
|
541
|
+
* An annotation attached to a message, rendered as a folded-corner box.
|
|
542
|
+
*/
|
|
543
|
+
interface SequenceNote {
|
|
544
|
+
kind: 'note';
|
|
545
|
+
text: string;
|
|
546
|
+
position: 'right' | 'left';
|
|
547
|
+
participantId: string;
|
|
548
|
+
lineNumber: number;
|
|
549
|
+
endLineNumber: number;
|
|
550
|
+
}
|
|
551
|
+
type SequenceElement = SequenceMessage | SequenceBlock | SequenceSection | SequenceNote;
|
|
536
552
|
declare function isSequenceBlock(el: SequenceElement): el is SequenceBlock;
|
|
553
|
+
declare function isSequenceNote(el: SequenceElement): el is SequenceNote;
|
|
537
554
|
/**
|
|
538
555
|
* A named group of participants rendered as a labeled box.
|
|
539
556
|
*/
|
|
@@ -617,6 +634,95 @@ declare function buildMermaidQuadrant(parsed: ParsedQuadrant, options?: {
|
|
|
617
634
|
mutedTextColor?: string;
|
|
618
635
|
}): string;
|
|
619
636
|
|
|
637
|
+
type GraphShape = 'terminal' | 'process' | 'decision' | 'io' | 'subroutine' | 'document';
|
|
638
|
+
type GraphDirection = 'TB' | 'LR';
|
|
639
|
+
interface GraphNode {
|
|
640
|
+
id: string;
|
|
641
|
+
label: string;
|
|
642
|
+
shape: GraphShape;
|
|
643
|
+
color?: string;
|
|
644
|
+
group?: string;
|
|
645
|
+
lineNumber: number;
|
|
646
|
+
}
|
|
647
|
+
interface GraphEdge {
|
|
648
|
+
source: string;
|
|
649
|
+
target: string;
|
|
650
|
+
label?: string;
|
|
651
|
+
color?: string;
|
|
652
|
+
lineNumber: number;
|
|
653
|
+
}
|
|
654
|
+
interface GraphGroup {
|
|
655
|
+
id: string;
|
|
656
|
+
label: string;
|
|
657
|
+
color?: string;
|
|
658
|
+
nodeIds: string[];
|
|
659
|
+
lineNumber: number;
|
|
660
|
+
}
|
|
661
|
+
interface ParsedGraph {
|
|
662
|
+
type: 'flowchart';
|
|
663
|
+
title?: string;
|
|
664
|
+
direction: GraphDirection;
|
|
665
|
+
nodes: GraphNode[];
|
|
666
|
+
edges: GraphEdge[];
|
|
667
|
+
groups?: GraphGroup[];
|
|
668
|
+
error?: string;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
declare function parseFlowchart(content: string, palette?: PaletteColors): ParsedGraph;
|
|
672
|
+
/**
|
|
673
|
+
* Detect if content looks like a flowchart (without explicit `chart: flowchart` header).
|
|
674
|
+
* Checks for shape delimiters combined with `->` arrows.
|
|
675
|
+
* Avoids false-positives on sequence diagrams (which use bare names with `->`)
|
|
676
|
+
*/
|
|
677
|
+
declare function looksLikeFlowchart(content: string): boolean;
|
|
678
|
+
|
|
679
|
+
interface LayoutNode {
|
|
680
|
+
id: string;
|
|
681
|
+
label: string;
|
|
682
|
+
shape: GraphShape;
|
|
683
|
+
color?: string;
|
|
684
|
+
group?: string;
|
|
685
|
+
lineNumber: number;
|
|
686
|
+
x: number;
|
|
687
|
+
y: number;
|
|
688
|
+
width: number;
|
|
689
|
+
height: number;
|
|
690
|
+
}
|
|
691
|
+
interface LayoutEdge {
|
|
692
|
+
source: string;
|
|
693
|
+
target: string;
|
|
694
|
+
points: {
|
|
695
|
+
x: number;
|
|
696
|
+
y: number;
|
|
697
|
+
}[];
|
|
698
|
+
label?: string;
|
|
699
|
+
color?: string;
|
|
700
|
+
lineNumber: number;
|
|
701
|
+
}
|
|
702
|
+
interface LayoutGroup {
|
|
703
|
+
id: string;
|
|
704
|
+
label: string;
|
|
705
|
+
color?: string;
|
|
706
|
+
x: number;
|
|
707
|
+
y: number;
|
|
708
|
+
width: number;
|
|
709
|
+
height: number;
|
|
710
|
+
}
|
|
711
|
+
interface LayoutResult {
|
|
712
|
+
nodes: LayoutNode[];
|
|
713
|
+
edges: LayoutEdge[];
|
|
714
|
+
groups: LayoutGroup[];
|
|
715
|
+
width: number;
|
|
716
|
+
height: number;
|
|
717
|
+
}
|
|
718
|
+
declare function layoutGraph(graph: ParsedGraph): LayoutResult;
|
|
719
|
+
|
|
720
|
+
declare function renderFlowchart(container: HTMLDivElement, graph: ParsedGraph, layout: LayoutResult, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: {
|
|
721
|
+
width?: number;
|
|
722
|
+
height?: number;
|
|
723
|
+
}): void;
|
|
724
|
+
declare function renderFlowchartForExport(content: string, theme: 'light' | 'dark' | 'transparent', palette: PaletteColors): string;
|
|
725
|
+
|
|
620
726
|
interface SectionMessageGroup {
|
|
621
727
|
section: SequenceSection;
|
|
622
728
|
messageIndices: number[];
|
|
@@ -705,4 +811,4 @@ declare function resolveColor(color: string, palette?: {
|
|
|
705
811
|
/** @deprecated Use getSeriesColors(palette) from '@/lib/palettes' instead. */
|
|
706
812
|
declare const seriesColors: string[];
|
|
707
813
|
|
|
708
|
-
export { type Activation, type ArcLink, type ArcNodeGroup, type ChartDataPoint, type ChartType, type D3ChartType, type D3ExportDimensions, DGMO_CHART_TYPE_MAP, type DgmoFramework, type EChartsChartType, type PaletteColors, type PaletteConfig, type ParsedChart, type ParsedD3, type ParsedEChart, type ParsedQuadrant, type ParsedSequenceDgmo, type ParticipantType, RULE_COUNT, type RenderStep, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, 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, isValidHex, looksLikeSequence, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseChart, parseD3, parseDgmoChartType, parseEChart, parseQuadrant, parseSequenceDgmo, parseTimelineDate, registerPalette, renderArcDiagram, renderD3ForExport, renderEChartsForExport, renderQuadrant, renderSequenceDiagram, renderSlopeChart, renderTimeline, renderVenn, renderWordCloud, resolveColor, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette };
|
|
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 };
|