@diagrammo/dgmo 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +107 -107
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +40 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/infra/layout.ts +6 -3
- package/src/infra/parser.ts +2 -2
- package/src/infra/renderer.ts +52 -8
- package/src/sharing.ts +8 -0
package/dist/index.d.cts
CHANGED
|
@@ -1786,7 +1786,7 @@ interface InfraLayoutResult {
|
|
|
1786
1786
|
width: number;
|
|
1787
1787
|
height: number;
|
|
1788
1788
|
}
|
|
1789
|
-
declare function layoutInfra(computed: ComputedInfraModel, selectedNodeId?: string | null): InfraLayoutResult;
|
|
1789
|
+
declare function layoutInfra(computed: ComputedInfraModel, selectedNodeId?: string | null, collapsedNodes?: Set<string> | null): InfraLayoutResult;
|
|
1790
1790
|
|
|
1791
1791
|
interface InfraLegendEntry {
|
|
1792
1792
|
value: string;
|
|
@@ -1811,7 +1811,7 @@ interface InfraPlaybackState {
|
|
|
1811
1811
|
speed: number;
|
|
1812
1812
|
speedOptions: readonly number[];
|
|
1813
1813
|
}
|
|
1814
|
-
declare function renderInfra(container: HTMLDivElement, layout: InfraLayoutResult, palette: PaletteColors, isDark: boolean, title: string | null, titleLineNumber: number | null, tagGroups?: InfraTagGroup[], activeGroup?: string | null, animate?: boolean, playback?: InfraPlaybackState | null, selectedNodeId?: string | null, exportMode?: boolean): void;
|
|
1814
|
+
declare function renderInfra(container: HTMLDivElement, layout: InfraLayoutResult, palette: PaletteColors, isDark: boolean, title: string | null, titleLineNumber: number | null, tagGroups?: InfraTagGroup[], activeGroup?: string | null, animate?: boolean, playback?: InfraPlaybackState | null, selectedNodeId?: string | null, exportMode?: boolean, collapsedNodes?: Set<string> | null): void;
|
|
1815
1815
|
declare function parseAndLayoutInfra(content: string): {
|
|
1816
1816
|
parsed: ParsedInfra;
|
|
1817
1817
|
computed: null;
|
|
@@ -1969,6 +1969,7 @@ declare const seriesColors: string[];
|
|
|
1969
1969
|
|
|
1970
1970
|
interface DiagramViewState {
|
|
1971
1971
|
activeTagGroup?: string;
|
|
1972
|
+
collapsedGroups?: string[];
|
|
1972
1973
|
}
|
|
1973
1974
|
interface DecodedDiagramUrl {
|
|
1974
1975
|
dsl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1786,7 +1786,7 @@ interface InfraLayoutResult {
|
|
|
1786
1786
|
width: number;
|
|
1787
1787
|
height: number;
|
|
1788
1788
|
}
|
|
1789
|
-
declare function layoutInfra(computed: ComputedInfraModel, selectedNodeId?: string | null): InfraLayoutResult;
|
|
1789
|
+
declare function layoutInfra(computed: ComputedInfraModel, selectedNodeId?: string | null, collapsedNodes?: Set<string> | null): InfraLayoutResult;
|
|
1790
1790
|
|
|
1791
1791
|
interface InfraLegendEntry {
|
|
1792
1792
|
value: string;
|
|
@@ -1811,7 +1811,7 @@ interface InfraPlaybackState {
|
|
|
1811
1811
|
speed: number;
|
|
1812
1812
|
speedOptions: readonly number[];
|
|
1813
1813
|
}
|
|
1814
|
-
declare function renderInfra(container: HTMLDivElement, layout: InfraLayoutResult, palette: PaletteColors, isDark: boolean, title: string | null, titleLineNumber: number | null, tagGroups?: InfraTagGroup[], activeGroup?: string | null, animate?: boolean, playback?: InfraPlaybackState | null, selectedNodeId?: string | null, exportMode?: boolean): void;
|
|
1814
|
+
declare function renderInfra(container: HTMLDivElement, layout: InfraLayoutResult, palette: PaletteColors, isDark: boolean, title: string | null, titleLineNumber: number | null, tagGroups?: InfraTagGroup[], activeGroup?: string | null, animate?: boolean, playback?: InfraPlaybackState | null, selectedNodeId?: string | null, exportMode?: boolean, collapsedNodes?: Set<string> | null): void;
|
|
1815
1815
|
declare function parseAndLayoutInfra(content: string): {
|
|
1816
1816
|
parsed: ParsedInfra;
|
|
1817
1817
|
computed: null;
|
|
@@ -1969,6 +1969,7 @@ declare const seriesColors: string[];
|
|
|
1969
1969
|
|
|
1970
1970
|
interface DiagramViewState {
|
|
1971
1971
|
activeTagGroup?: string;
|
|
1972
|
+
collapsedGroups?: string[];
|
|
1972
1973
|
}
|
|
1973
1974
|
interface DecodedDiagramUrl {
|
|
1974
1975
|
dsl: string;
|
package/dist/index.js
CHANGED
|
@@ -7190,7 +7190,7 @@ var init_parser9 = __esm({
|
|
|
7190
7190
|
TAG_GROUP_RE = /^tag\s*:\s*(\w[\w\s]*?)(?:\s+alias\s+(\w+))?\s*$/;
|
|
7191
7191
|
TAG_VALUE_RE = /^(\w[\w\s]*?)(?:\(([^)]+)\))?(\s+default)?\s*$/;
|
|
7192
7192
|
COMPONENT_RE = /^([a-zA-Z_][\w]*)(.*)$/;
|
|
7193
|
-
PIPE_META_RE =
|
|
7193
|
+
PIPE_META_RE = /[|,]\s*(\w+)\s*:\s*([^|,]+)/g;
|
|
7194
7194
|
PROPERTY_RE = /^([\w-]+)\s*:\s*(.+)$/;
|
|
7195
7195
|
PERCENT_RE = /^([\d.]+)%$/;
|
|
7196
7196
|
RANGE_RE = /^(\d+)-(\d+)$/;
|
|
@@ -15015,7 +15015,7 @@ function formatUptime(fraction) {
|
|
|
15015
15015
|
if (pct >= 99) return `${pct.toFixed(1)}%`;
|
|
15016
15016
|
return `${pct.toFixed(1)}%`;
|
|
15017
15017
|
}
|
|
15018
|
-
function layoutInfra(computed, selectedNodeId) {
|
|
15018
|
+
function layoutInfra(computed, selectedNodeId, collapsedNodes) {
|
|
15019
15019
|
if (computed.nodes.length === 0) {
|
|
15020
15020
|
return { nodes: [], edges: [], groups: [], options: {}, width: 0, height: 0 };
|
|
15021
15021
|
}
|
|
@@ -15036,9 +15036,10 @@ function layoutInfra(computed, selectedNodeId) {
|
|
|
15036
15036
|
const widthMap = /* @__PURE__ */ new Map();
|
|
15037
15037
|
const heightMap = /* @__PURE__ */ new Map();
|
|
15038
15038
|
for (const node of computed.nodes) {
|
|
15039
|
-
const
|
|
15039
|
+
const isNodeCollapsed = collapsedNodes?.has(node.id) ?? false;
|
|
15040
|
+
const expanded = !isNodeCollapsed && node.id === selectedNodeId;
|
|
15040
15041
|
const width = computeNodeWidth2(node, expanded, computed.options);
|
|
15041
|
-
const height = computeNodeHeight2(node, expanded, computed.options);
|
|
15042
|
+
const height = isNodeCollapsed ? NODE_HEADER_HEIGHT + NODE_PAD_BOTTOM : computeNodeHeight2(node, expanded, computed.options);
|
|
15042
15043
|
widthMap.set(node.id, width);
|
|
15043
15044
|
heightMap.set(node.id, height);
|
|
15044
15045
|
const inGroup = groupedNodeIds.has(node.id);
|
|
@@ -15612,10 +15613,27 @@ function renderEdgeLabels(svg, edges, palette, isDark, animate) {
|
|
|
15612
15613
|
}
|
|
15613
15614
|
}
|
|
15614
15615
|
}
|
|
15615
|
-
function
|
|
15616
|
+
function resolveActiveTagStroke(node, activeGroup, tagGroups, palette) {
|
|
15617
|
+
const tg = tagGroups.find((t) => t.name.toLowerCase() === activeGroup.toLowerCase());
|
|
15618
|
+
if (!tg) return null;
|
|
15619
|
+
const tagKey = (tg.alias ?? tg.name).toLowerCase();
|
|
15620
|
+
const tagVal = node.tags[tagKey];
|
|
15621
|
+
if (!tagVal) return null;
|
|
15622
|
+
const tv = tg.values.find((v) => v.name.toLowerCase() === tagVal.toLowerCase());
|
|
15623
|
+
if (!tv?.color) return null;
|
|
15624
|
+
return resolveColor(tv.color, palette);
|
|
15625
|
+
}
|
|
15626
|
+
function renderNodes(svg, nodes, palette, isDark, animate, selectedNodeId, activeGroup, diagramOptions, collapsedNodes, tagGroups) {
|
|
15616
15627
|
const mutedColor = palette.textMuted;
|
|
15617
15628
|
for (const node of nodes) {
|
|
15618
|
-
|
|
15629
|
+
let { fill: fill2, stroke: stroke2, textFill } = nodeColor(node, palette, isDark);
|
|
15630
|
+
if (activeGroup && tagGroups && !node.isEdge) {
|
|
15631
|
+
const tagStroke = resolveActiveTagStroke(node, activeGroup, tagGroups, palette);
|
|
15632
|
+
if (tagStroke) {
|
|
15633
|
+
stroke2 = tagStroke;
|
|
15634
|
+
fill2 = mix(palette.bg, tagStroke, isDark ? 88 : 94);
|
|
15635
|
+
}
|
|
15636
|
+
}
|
|
15619
15637
|
let cls = "infra-node";
|
|
15620
15638
|
if (animate && node.isEdge) {
|
|
15621
15639
|
cls += " infra-node-edge-throb";
|
|
@@ -15625,9 +15643,9 @@ function renderNodes(svg, nodes, palette, isDark, animate, selectedNodeId, activ
|
|
|
15625
15643
|
else if (severity === "overloaded") cls += " infra-node-overload";
|
|
15626
15644
|
else if (severity === "warning") cls += " infra-node-warning";
|
|
15627
15645
|
}
|
|
15628
|
-
const g = svg.append("g").attr("class", cls).attr("data-line-number", node.lineNumber).attr("data-infra-node", node.id);
|
|
15646
|
+
const g = svg.append("g").attr("class", cls).attr("data-line-number", node.lineNumber).attr("data-infra-node", node.id).attr("data-node-collapse", node.id).style("cursor", "pointer");
|
|
15629
15647
|
if (node.id.startsWith("[")) {
|
|
15630
|
-
g.attr("data-node-toggle", node.id)
|
|
15648
|
+
g.attr("data-node-toggle", node.id);
|
|
15631
15649
|
}
|
|
15632
15650
|
for (const [tagKey, tagVal] of Object.entries(node.tags)) {
|
|
15633
15651
|
g.attr(`data-tag-${tagKey.toLowerCase()}`, tagVal.toLowerCase());
|
|
@@ -15645,7 +15663,12 @@ function renderNodes(svg, nodes, palette, isDark, animate, selectedNodeId, activ
|
|
|
15645
15663
|
g.append("rect").attr("x", x).attr("y", y).attr("width", node.width).attr("height", node.height).attr("rx", NODE_BORDER_RADIUS).attr("fill", fill2).attr("stroke", stroke2).attr("stroke-width", strokeWidth);
|
|
15646
15664
|
const headerCenterY = y + NODE_HEADER_HEIGHT2 / 2 + NODE_FONT_SIZE3 * 0.35;
|
|
15647
15665
|
g.append("text").attr("x", node.x).attr("y", headerCenterY).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", NODE_FONT_SIZE3).attr("font-weight", "600").attr("fill", textFill).text(node.label);
|
|
15648
|
-
|
|
15666
|
+
const isNodeCollapsed = collapsedNodes?.has(node.id) ?? false;
|
|
15667
|
+
if (isNodeCollapsed) {
|
|
15668
|
+
const chevronY = y + node.height - 6;
|
|
15669
|
+
g.append("text").attr("x", node.x).attr("y", chevronY).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", 8).attr("fill", textFill).attr("opacity", 0.5).text("\u25BC");
|
|
15670
|
+
}
|
|
15671
|
+
if (!isNodeCollapsed) {
|
|
15649
15672
|
const expanded = node.id === selectedNodeId;
|
|
15650
15673
|
const displayProps = !node.isEdge && expanded ? getDisplayProps(node, expanded, diagramOptions) : [];
|
|
15651
15674
|
const computedRows = getComputedRows(node, expanded);
|
|
@@ -15968,7 +15991,7 @@ function renderLegend3(rootSvg, legendGroups, totalWidth, legendY, palette, isDa
|
|
|
15968
15991
|
cursorX += fullW + LEGEND_GROUP_GAP5;
|
|
15969
15992
|
}
|
|
15970
15993
|
}
|
|
15971
|
-
function renderInfra(container, layout, palette, isDark, title, titleLineNumber, tagGroups, activeGroup, animate, playback, selectedNodeId, exportMode) {
|
|
15994
|
+
function renderInfra(container, layout, palette, isDark, title, titleLineNumber, tagGroups, activeGroup, animate, playback, selectedNodeId, exportMode, collapsedNodes) {
|
|
15972
15995
|
d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
|
|
15973
15996
|
const legendGroups = computeInfraLegendGroups(layout.nodes, tagGroups ?? [], palette);
|
|
15974
15997
|
const hasLegend = legendGroups.length > 0 || !!playback;
|
|
@@ -16027,7 +16050,7 @@ function renderInfra(container, layout, palette, isDark, title, titleLineNumber,
|
|
|
16027
16050
|
}
|
|
16028
16051
|
renderGroups(svg, layout.groups, palette, isDark);
|
|
16029
16052
|
renderEdgePaths(svg, layout.edges, layout.nodes, palette, isDark, shouldAnimate);
|
|
16030
|
-
renderNodes(svg, layout.nodes, palette, isDark, shouldAnimate, selectedNodeId, activeGroup, layout.options);
|
|
16053
|
+
renderNodes(svg, layout.nodes, palette, isDark, shouldAnimate, selectedNodeId, activeGroup, layout.options, collapsedNodes, tagGroups ?? []);
|
|
16031
16054
|
if (shouldAnimate) {
|
|
16032
16055
|
renderRejectParticles(svg, layout.nodes);
|
|
16033
16056
|
}
|
|
@@ -21623,6 +21646,9 @@ function encodeDiagramUrl(dsl, options) {
|
|
|
21623
21646
|
if (options?.viewState?.activeTagGroup) {
|
|
21624
21647
|
hash += `&tag=${encodeURIComponent(options.viewState.activeTagGroup)}`;
|
|
21625
21648
|
}
|
|
21649
|
+
if (options?.viewState?.collapsedGroups?.length) {
|
|
21650
|
+
hash += `&cg=${encodeURIComponent(options.viewState.collapsedGroups.join(","))}`;
|
|
21651
|
+
}
|
|
21626
21652
|
return { url: `${baseUrl}?${hash}#${hash}` };
|
|
21627
21653
|
}
|
|
21628
21654
|
function decodeDiagramUrl(hash) {
|
|
@@ -21643,6 +21669,9 @@ function decodeDiagramUrl(hash) {
|
|
|
21643
21669
|
if (key === "tag" && val) {
|
|
21644
21670
|
viewState.activeTagGroup = val;
|
|
21645
21671
|
}
|
|
21672
|
+
if (key === "cg" && val) {
|
|
21673
|
+
viewState.collapsedGroups = val.split(",").filter(Boolean);
|
|
21674
|
+
}
|
|
21646
21675
|
}
|
|
21647
21676
|
if (payload.startsWith("dgmo=")) {
|
|
21648
21677
|
payload = payload.slice(5);
|