@diagrammo/dgmo 0.2.28 → 0.3.1
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/.claude/skills/dgmo-chart/SKILL.md +6 -0
- package/README.md +5 -0
- package/dist/cli.cjs +361 -921
- package/dist/index.cjs +184 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +184 -107
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +51 -14
- package/package.json +6 -6
- package/src/chart.ts +12 -6
- package/src/class/layout.ts +17 -12
- package/src/class/parser.ts +20 -42
- package/src/class/renderer.ts +44 -46
- package/src/d3.ts +23 -6
- package/src/echarts.ts +25 -7
- package/src/sequence/parser.ts +16 -3
- package/src/sequence/renderer.ts +22 -0
- package/src/utils/parsing.ts +31 -0
package/dist/index.d.cts
CHANGED
|
@@ -579,6 +579,8 @@ interface SequenceMessage {
|
|
|
579
579
|
lineNumber: number;
|
|
580
580
|
async?: boolean;
|
|
581
581
|
bidirectional?: boolean;
|
|
582
|
+
/** Standalone return — the message itself IS a return (dashed arrow, no call). */
|
|
583
|
+
standaloneReturn?: boolean;
|
|
582
584
|
}
|
|
583
585
|
/**
|
|
584
586
|
* A conditional or loop block in the sequence diagram.
|
package/dist/index.d.ts
CHANGED
|
@@ -579,6 +579,8 @@ interface SequenceMessage {
|
|
|
579
579
|
lineNumber: number;
|
|
580
580
|
async?: boolean;
|
|
581
581
|
bidirectional?: boolean;
|
|
582
|
+
/** Standalone return — the message itself IS a return (dashed arrow, no call). */
|
|
583
|
+
standaloneReturn?: boolean;
|
|
582
584
|
}
|
|
583
585
|
/**
|
|
584
586
|
* A conditional or loop block in the sequence diagram.
|
package/dist/index.js
CHANGED
|
@@ -1253,6 +1253,67 @@ var init_palettes = __esm({
|
|
|
1253
1253
|
}
|
|
1254
1254
|
});
|
|
1255
1255
|
|
|
1256
|
+
// src/utils/parsing.ts
|
|
1257
|
+
function measureIndent(line7) {
|
|
1258
|
+
let indent = 0;
|
|
1259
|
+
for (const ch of line7) {
|
|
1260
|
+
if (ch === " ") indent++;
|
|
1261
|
+
else if (ch === " ") indent += 4;
|
|
1262
|
+
else break;
|
|
1263
|
+
}
|
|
1264
|
+
return indent;
|
|
1265
|
+
}
|
|
1266
|
+
function extractColor(label, palette) {
|
|
1267
|
+
const m = label.match(COLOR_SUFFIX_RE);
|
|
1268
|
+
if (!m) return { label };
|
|
1269
|
+
const colorName = m[1].trim();
|
|
1270
|
+
return {
|
|
1271
|
+
label: label.substring(0, m.index).trim(),
|
|
1272
|
+
color: resolveColor(colorName, palette)
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
function collectIndentedValues(lines, startIndex) {
|
|
1276
|
+
const values = [];
|
|
1277
|
+
let j = startIndex + 1;
|
|
1278
|
+
for (; j < lines.length; j++) {
|
|
1279
|
+
const raw = lines[j];
|
|
1280
|
+
const trimmed = raw.trim();
|
|
1281
|
+
if (!trimmed) continue;
|
|
1282
|
+
if (trimmed.startsWith("//")) continue;
|
|
1283
|
+
if (raw[0] !== " " && raw[0] !== " ") break;
|
|
1284
|
+
values.push(trimmed.replace(/,\s*$/, ""));
|
|
1285
|
+
}
|
|
1286
|
+
return { values, newIndex: j - 1 };
|
|
1287
|
+
}
|
|
1288
|
+
function parsePipeMetadata(segments, aliasMap = /* @__PURE__ */ new Map()) {
|
|
1289
|
+
const metadata = {};
|
|
1290
|
+
for (let j = 1; j < segments.length; j++) {
|
|
1291
|
+
for (const part of segments[j].split(",")) {
|
|
1292
|
+
const trimmedPart = part.trim();
|
|
1293
|
+
if (!trimmedPart) continue;
|
|
1294
|
+
const colonIdx = trimmedPart.indexOf(":");
|
|
1295
|
+
if (colonIdx > 0) {
|
|
1296
|
+
const rawKey = trimmedPart.substring(0, colonIdx).trim().toLowerCase();
|
|
1297
|
+
const key = aliasMap.get(rawKey) ?? rawKey;
|
|
1298
|
+
const value = trimmedPart.substring(colonIdx + 1).trim();
|
|
1299
|
+
metadata[key] = value;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return metadata;
|
|
1304
|
+
}
|
|
1305
|
+
var COLOR_SUFFIX_RE, CHART_TYPE_RE, TITLE_RE, OPTION_RE;
|
|
1306
|
+
var init_parsing = __esm({
|
|
1307
|
+
"src/utils/parsing.ts"() {
|
|
1308
|
+
"use strict";
|
|
1309
|
+
init_colors();
|
|
1310
|
+
COLOR_SUFFIX_RE = /\(([^)]+)\)\s*$/;
|
|
1311
|
+
CHART_TYPE_RE = /^chart\s*:\s*(.+)/i;
|
|
1312
|
+
TITLE_RE = /^title\s*:\s*(.+)/i;
|
|
1313
|
+
OPTION_RE = /^([a-z][a-z0-9-]*)\s*:\s*(.+)$/i;
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1256
1317
|
// src/sequence/participant-inference.ts
|
|
1257
1318
|
function inferParticipantType(name) {
|
|
1258
1319
|
for (const rule of PARTICIPANT_RULES) {
|
|
@@ -1569,54 +1630,6 @@ var init_arrows = __esm({
|
|
|
1569
1630
|
}
|
|
1570
1631
|
});
|
|
1571
1632
|
|
|
1572
|
-
// src/utils/parsing.ts
|
|
1573
|
-
function measureIndent(line7) {
|
|
1574
|
-
let indent = 0;
|
|
1575
|
-
for (const ch of line7) {
|
|
1576
|
-
if (ch === " ") indent++;
|
|
1577
|
-
else if (ch === " ") indent += 4;
|
|
1578
|
-
else break;
|
|
1579
|
-
}
|
|
1580
|
-
return indent;
|
|
1581
|
-
}
|
|
1582
|
-
function extractColor(label, palette) {
|
|
1583
|
-
const m = label.match(COLOR_SUFFIX_RE);
|
|
1584
|
-
if (!m) return { label };
|
|
1585
|
-
const colorName = m[1].trim();
|
|
1586
|
-
return {
|
|
1587
|
-
label: label.substring(0, m.index).trim(),
|
|
1588
|
-
color: resolveColor(colorName, palette)
|
|
1589
|
-
};
|
|
1590
|
-
}
|
|
1591
|
-
function parsePipeMetadata(segments, aliasMap = /* @__PURE__ */ new Map()) {
|
|
1592
|
-
const metadata = {};
|
|
1593
|
-
for (let j = 1; j < segments.length; j++) {
|
|
1594
|
-
for (const part of segments[j].split(",")) {
|
|
1595
|
-
const trimmedPart = part.trim();
|
|
1596
|
-
if (!trimmedPart) continue;
|
|
1597
|
-
const colonIdx = trimmedPart.indexOf(":");
|
|
1598
|
-
if (colonIdx > 0) {
|
|
1599
|
-
const rawKey = trimmedPart.substring(0, colonIdx).trim().toLowerCase();
|
|
1600
|
-
const key = aliasMap.get(rawKey) ?? rawKey;
|
|
1601
|
-
const value = trimmedPart.substring(colonIdx + 1).trim();
|
|
1602
|
-
metadata[key] = value;
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
return metadata;
|
|
1607
|
-
}
|
|
1608
|
-
var COLOR_SUFFIX_RE, CHART_TYPE_RE, TITLE_RE, OPTION_RE;
|
|
1609
|
-
var init_parsing = __esm({
|
|
1610
|
-
"src/utils/parsing.ts"() {
|
|
1611
|
-
"use strict";
|
|
1612
|
-
init_colors();
|
|
1613
|
-
COLOR_SUFFIX_RE = /\(([^)]+)\)\s*$/;
|
|
1614
|
-
CHART_TYPE_RE = /^chart\s*:\s*(.+)/i;
|
|
1615
|
-
TITLE_RE = /^title\s*:\s*(.+)/i;
|
|
1616
|
-
OPTION_RE = /^([a-z][a-z0-9-]*)\s*:\s*(.+)$/i;
|
|
1617
|
-
}
|
|
1618
|
-
});
|
|
1619
|
-
|
|
1620
1633
|
// src/sequence/parser.ts
|
|
1621
1634
|
var parser_exports = {};
|
|
1622
1635
|
__export(parser_exports, {
|
|
@@ -1637,6 +1650,13 @@ function isSequenceNote(el) {
|
|
|
1637
1650
|
}
|
|
1638
1651
|
function parseReturnLabel(rawLabel) {
|
|
1639
1652
|
if (!rawLabel) return { label: "" };
|
|
1653
|
+
const standaloneMatch = rawLabel.match(/^<-\s*(.*)$/);
|
|
1654
|
+
if (standaloneMatch) {
|
|
1655
|
+
return {
|
|
1656
|
+
label: standaloneMatch[1].trim(),
|
|
1657
|
+
standaloneReturn: true
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1640
1660
|
const arrowReturn = rawLabel.match(ARROW_RETURN_PATTERN);
|
|
1641
1661
|
if (arrowReturn) {
|
|
1642
1662
|
return { label: arrowReturn[1].trim(), returnLabel: arrowReturn[2].trim() };
|
|
@@ -1974,14 +1994,15 @@ function parseSequenceDgmo(content) {
|
|
|
1974
1994
|
const to = arrowMatch[2];
|
|
1975
1995
|
lastMsgFrom = from;
|
|
1976
1996
|
const rawLabel = arrowMatch[3]?.trim() || "";
|
|
1977
|
-
const { label, returnLabel } = isAsync ? { label: rawLabel, returnLabel: void 0 } : parseReturnLabel(rawLabel);
|
|
1997
|
+
const { label, returnLabel, standaloneReturn } = isAsync ? { label: rawLabel, returnLabel: void 0, standaloneReturn: void 0 } : parseReturnLabel(rawLabel);
|
|
1978
1998
|
const msg = {
|
|
1979
1999
|
from,
|
|
1980
2000
|
to,
|
|
1981
2001
|
label,
|
|
1982
2002
|
returnLabel,
|
|
1983
2003
|
lineNumber,
|
|
1984
|
-
...isAsync ? { async: true } : {}
|
|
2004
|
+
...isAsync ? { async: true } : {},
|
|
2005
|
+
...standaloneReturn ? { standaloneReturn: true } : {}
|
|
1985
2006
|
};
|
|
1986
2007
|
result.messages.push(msg);
|
|
1987
2008
|
currentContainer().push(msg);
|
|
@@ -2688,23 +2709,6 @@ function parseClassDiagram(content, palette) {
|
|
|
2688
2709
|
}
|
|
2689
2710
|
currentClass = null;
|
|
2690
2711
|
contentStarted = true;
|
|
2691
|
-
const relKeyword = trimmed.match(REL_KEYWORD_RE);
|
|
2692
|
-
if (relKeyword) {
|
|
2693
|
-
const sourceName = relKeyword[1];
|
|
2694
|
-
const keyword = relKeyword[2].toLowerCase();
|
|
2695
|
-
const targetName = relKeyword[3];
|
|
2696
|
-
const label = relKeyword[4]?.trim();
|
|
2697
|
-
getOrCreateClass(sourceName, lineNumber);
|
|
2698
|
-
getOrCreateClass(targetName, lineNumber);
|
|
2699
|
-
result.relationships.push({
|
|
2700
|
-
source: classId(sourceName),
|
|
2701
|
-
target: classId(targetName),
|
|
2702
|
-
type: KEYWORD_TO_TYPE[keyword],
|
|
2703
|
-
...label && { label },
|
|
2704
|
-
lineNumber
|
|
2705
|
-
});
|
|
2706
|
-
continue;
|
|
2707
|
-
}
|
|
2708
2712
|
const relArrow = trimmed.match(REL_ARROW_RE);
|
|
2709
2713
|
if (relArrow) {
|
|
2710
2714
|
const sourceName = relArrow[1];
|
|
@@ -2725,13 +2729,24 @@ function parseClassDiagram(content, palette) {
|
|
|
2725
2729
|
const classDecl = trimmed.match(CLASS_DECL_RE);
|
|
2726
2730
|
if (classDecl) {
|
|
2727
2731
|
const name = classDecl[1];
|
|
2728
|
-
const
|
|
2729
|
-
const
|
|
2732
|
+
const relKeyword = classDecl[2];
|
|
2733
|
+
const parentName = classDecl[3];
|
|
2734
|
+
const modifier = classDecl[4];
|
|
2735
|
+
const colorName = classDecl[5]?.trim();
|
|
2730
2736
|
const color = colorName ? resolveColor(colorName, palette) : void 0;
|
|
2731
2737
|
const node = getOrCreateClass(name, lineNumber);
|
|
2732
2738
|
if (modifier) node.modifier = modifier;
|
|
2733
2739
|
if (color) node.color = color;
|
|
2734
2740
|
node.lineNumber = lineNumber;
|
|
2741
|
+
if (relKeyword && parentName) {
|
|
2742
|
+
getOrCreateClass(parentName, lineNumber);
|
|
2743
|
+
result.relationships.push({
|
|
2744
|
+
source: classId(name),
|
|
2745
|
+
target: classId(parentName),
|
|
2746
|
+
type: relKeyword,
|
|
2747
|
+
lineNumber
|
|
2748
|
+
});
|
|
2749
|
+
}
|
|
2735
2750
|
currentClass = node;
|
|
2736
2751
|
continue;
|
|
2737
2752
|
}
|
|
@@ -2771,8 +2786,9 @@ function looksLikeClassDiagram(content) {
|
|
|
2771
2786
|
hasModifier = true;
|
|
2772
2787
|
hasClassDecl = true;
|
|
2773
2788
|
}
|
|
2774
|
-
if (
|
|
2789
|
+
if (/^[A-Z][A-Za-z0-9_]*\s+(extends|implements)\s+[A-Z]/.test(trimmed)) {
|
|
2775
2790
|
hasRelationship = true;
|
|
2791
|
+
hasClassDecl = true;
|
|
2776
2792
|
}
|
|
2777
2793
|
if (REL_ARROW_RE.test(trimmed)) {
|
|
2778
2794
|
hasRelationship = true;
|
|
@@ -2790,27 +2806,19 @@ function looksLikeClassDiagram(content) {
|
|
|
2790
2806
|
if (hasRelationship && hasClassDecl && hasIndentedMember) return true;
|
|
2791
2807
|
return false;
|
|
2792
2808
|
}
|
|
2793
|
-
var CLASS_DECL_RE,
|
|
2809
|
+
var CLASS_DECL_RE, REL_ARROW_RE, VISIBILITY_RE, STATIC_SUFFIX_RE, METHOD_RE, FIELD_RE, ARROW_TO_TYPE;
|
|
2794
2810
|
var init_parser2 = __esm({
|
|
2795
2811
|
"src/class/parser.ts"() {
|
|
2796
2812
|
"use strict";
|
|
2797
2813
|
init_colors();
|
|
2798
2814
|
init_diagnostics();
|
|
2799
2815
|
init_parsing();
|
|
2800
|
-
CLASS_DECL_RE = /^([A-Z][A-Za-z0-9_]*)(?:\s+\[(abstract|interface|enum)\])?(?:\s+\(([^)]+)\))?\s*$/;
|
|
2801
|
-
REL_KEYWORD_RE = /^([A-Z][A-Za-z0-9_]*)\s+(extends|implements|contains|has|uses)\s+([A-Z][A-Za-z0-9_]*)(?:\s*:\s*(.+))?$/;
|
|
2816
|
+
CLASS_DECL_RE = /^([A-Z][A-Za-z0-9_]*)(?:\s+(extends|implements)\s+([A-Z][A-Za-z0-9_]*))?(?:\s+\[(abstract|interface|enum)\])?(?:\s+\(([^)]+)\))?\s*$/;
|
|
2802
2817
|
REL_ARROW_RE = /^([A-Z][A-Za-z0-9_]*)\s+(--\|>|\.\.\|>|\*--|o--|\.\.\>|->)\s+([A-Z][A-Za-z0-9_]*)(?:\s*:\s*(.+))?$/;
|
|
2803
2818
|
VISIBILITY_RE = /^([+\-#])\s*/;
|
|
2804
2819
|
STATIC_SUFFIX_RE = /\{static\}\s*$/;
|
|
2805
2820
|
METHOD_RE = /^(.+?)\(([^)]*)\)(?:\s*:\s*(.+))?$/;
|
|
2806
2821
|
FIELD_RE = /^(.+?)\s*:\s*(.+)$/;
|
|
2807
|
-
KEYWORD_TO_TYPE = {
|
|
2808
|
-
extends: "extends",
|
|
2809
|
-
implements: "implements",
|
|
2810
|
-
contains: "composes",
|
|
2811
|
-
has: "aggregates",
|
|
2812
|
-
uses: "depends"
|
|
2813
|
-
};
|
|
2814
2822
|
ARROW_TO_TYPE = {
|
|
2815
2823
|
"--|>": "extends",
|
|
2816
2824
|
"..|>": "implements",
|
|
@@ -2850,7 +2858,7 @@ function parseRelationship(trimmed, lineNumber, pushError) {
|
|
|
2850
2858
|
};
|
|
2851
2859
|
}
|
|
2852
2860
|
}
|
|
2853
|
-
const kw = trimmed.match(
|
|
2861
|
+
const kw = trimmed.match(REL_KEYWORD_RE);
|
|
2854
2862
|
if (kw) {
|
|
2855
2863
|
const fromSym = KEYWORD_TO_SYMBOL[kw[2].toLowerCase()] ?? kw[2];
|
|
2856
2864
|
const toSym = KEYWORD_TO_SYMBOL[kw[3].toLowerCase()] ?? kw[3];
|
|
@@ -3033,7 +3041,7 @@ function looksLikeERDiagram(content) {
|
|
|
3033
3041
|
if (hasRelationship && hasTableDecl && hasConstraint) return true;
|
|
3034
3042
|
return false;
|
|
3035
3043
|
}
|
|
3036
|
-
var TABLE_DECL_RE, COLUMN_RE, CONSTRAINT_MAP, REL_SYMBOLIC_RE,
|
|
3044
|
+
var TABLE_DECL_RE, COLUMN_RE, CONSTRAINT_MAP, REL_SYMBOLIC_RE, REL_KEYWORD_RE, KEYWORD_TO_SYMBOL;
|
|
3037
3045
|
var init_parser3 = __esm({
|
|
3038
3046
|
"src/er/parser.ts"() {
|
|
3039
3047
|
"use strict";
|
|
@@ -3049,7 +3057,7 @@ var init_parser3 = __esm({
|
|
|
3049
3057
|
nullable: "nullable"
|
|
3050
3058
|
};
|
|
3051
3059
|
REL_SYMBOLIC_RE = /^([a-zA-Z_]\w*)\s+([1*?])\s*-{1,2}\s*([1*?])\s+([a-zA-Z_]\w*)(?:\s*:\s*(.+))?$/;
|
|
3052
|
-
|
|
3060
|
+
REL_KEYWORD_RE = /^([a-zA-Z_]\w*)\s+(one|many|zero)[- ]to[- ](one|many|zero)\s+([a-zA-Z_]\w*)(?:\s*:\s*(.+))?$/i;
|
|
3053
3061
|
KEYWORD_TO_SYMBOL = {
|
|
3054
3062
|
one: "1",
|
|
3055
3063
|
many: "*",
|
|
@@ -3134,8 +3142,16 @@ function parseChart(content, palette) {
|
|
|
3134
3142
|
continue;
|
|
3135
3143
|
}
|
|
3136
3144
|
if (key === "series") {
|
|
3137
|
-
|
|
3138
|
-
|
|
3145
|
+
let rawNames;
|
|
3146
|
+
if (value) {
|
|
3147
|
+
result.series = value;
|
|
3148
|
+
rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
3149
|
+
} else {
|
|
3150
|
+
const collected = collectIndentedValues(lines, i);
|
|
3151
|
+
i = collected.newIndex;
|
|
3152
|
+
rawNames = collected.values;
|
|
3153
|
+
result.series = rawNames.join(", ");
|
|
3154
|
+
}
|
|
3139
3155
|
const names = [];
|
|
3140
3156
|
const nameColors = [];
|
|
3141
3157
|
for (const raw of rawNames) {
|
|
@@ -3214,6 +3230,7 @@ var init_chart = __esm({
|
|
|
3214
3230
|
"use strict";
|
|
3215
3231
|
init_colors();
|
|
3216
3232
|
init_diagnostics();
|
|
3233
|
+
init_parsing();
|
|
3217
3234
|
VALID_TYPES = /* @__PURE__ */ new Set([
|
|
3218
3235
|
"bar",
|
|
3219
3236
|
"line",
|
|
@@ -3290,8 +3307,16 @@ function parseEChart(content, palette) {
|
|
|
3290
3307
|
continue;
|
|
3291
3308
|
}
|
|
3292
3309
|
if (key === "series") {
|
|
3293
|
-
|
|
3294
|
-
|
|
3310
|
+
let rawNames;
|
|
3311
|
+
if (value) {
|
|
3312
|
+
result.series = value;
|
|
3313
|
+
rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
3314
|
+
} else {
|
|
3315
|
+
const collected = collectIndentedValues(lines, i);
|
|
3316
|
+
i = collected.newIndex;
|
|
3317
|
+
rawNames = collected.values;
|
|
3318
|
+
result.series = rawNames.join(", ");
|
|
3319
|
+
}
|
|
3295
3320
|
const names = [];
|
|
3296
3321
|
const nameColors = [];
|
|
3297
3322
|
for (const raw of rawNames) {
|
|
@@ -3327,11 +3352,23 @@ function parseEChart(content, palette) {
|
|
|
3327
3352
|
continue;
|
|
3328
3353
|
}
|
|
3329
3354
|
if (key === "columns") {
|
|
3330
|
-
|
|
3355
|
+
if (value) {
|
|
3356
|
+
result.columns = value.split(",").map((s) => s.trim());
|
|
3357
|
+
} else {
|
|
3358
|
+
const collected = collectIndentedValues(lines, i);
|
|
3359
|
+
i = collected.newIndex;
|
|
3360
|
+
result.columns = collected.values;
|
|
3361
|
+
}
|
|
3331
3362
|
continue;
|
|
3332
3363
|
}
|
|
3333
3364
|
if (key === "rows") {
|
|
3334
|
-
|
|
3365
|
+
if (value) {
|
|
3366
|
+
result.rows = value.split(",").map((s) => s.trim());
|
|
3367
|
+
} else {
|
|
3368
|
+
const collected = collectIndentedValues(lines, i);
|
|
3369
|
+
i = collected.newIndex;
|
|
3370
|
+
result.rows = collected.values;
|
|
3371
|
+
}
|
|
3335
3372
|
continue;
|
|
3336
3373
|
}
|
|
3337
3374
|
if (key === "x") {
|
|
@@ -4646,6 +4683,7 @@ var init_echarts = __esm({
|
|
|
4646
4683
|
init_palettes();
|
|
4647
4684
|
init_chart();
|
|
4648
4685
|
init_diagnostics();
|
|
4686
|
+
init_parsing();
|
|
4649
4687
|
ECHART_EXPORT_WIDTH = 1200;
|
|
4650
4688
|
ECHART_EXPORT_HEIGHT = 800;
|
|
4651
4689
|
STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -7732,22 +7770,30 @@ function computeNodeDimensions(node) {
|
|
|
7732
7770
|
}
|
|
7733
7771
|
const width = Math.max(MIN_WIDTH, maxTextLen * CHAR_WIDTH2 + PADDING_X);
|
|
7734
7772
|
const headerHeight = HEADER_BASE + (node.modifier ? MODIFIER_BADGE : 0);
|
|
7735
|
-
let fieldsHeight
|
|
7773
|
+
let fieldsHeight;
|
|
7736
7774
|
if (isEnum) {
|
|
7737
7775
|
const enumValues = node.members;
|
|
7738
7776
|
if (enumValues.length > 0) {
|
|
7739
7777
|
fieldsHeight = COMPARTMENT_PADDING_Y * 2 + enumValues.length * MEMBER_LINE_HEIGHT + SEPARATOR_HEIGHT;
|
|
7778
|
+
} else {
|
|
7779
|
+
fieldsHeight = SEPARATOR_HEIGHT + COMPARTMENT_PADDING_Y;
|
|
7740
7780
|
}
|
|
7741
7781
|
} else {
|
|
7742
7782
|
if (fields.length > 0) {
|
|
7743
7783
|
fieldsHeight = COMPARTMENT_PADDING_Y * 2 + fields.length * MEMBER_LINE_HEIGHT + SEPARATOR_HEIGHT;
|
|
7784
|
+
} else {
|
|
7785
|
+
fieldsHeight = SEPARATOR_HEIGHT + COMPARTMENT_PADDING_Y;
|
|
7744
7786
|
}
|
|
7745
7787
|
}
|
|
7746
7788
|
let methodsHeight = 0;
|
|
7747
|
-
if (!isEnum
|
|
7748
|
-
|
|
7789
|
+
if (!isEnum) {
|
|
7790
|
+
if (methods.length > 0) {
|
|
7791
|
+
methodsHeight = COMPARTMENT_PADDING_Y * 2 + methods.length * MEMBER_LINE_HEIGHT + SEPARATOR_HEIGHT;
|
|
7792
|
+
} else {
|
|
7793
|
+
methodsHeight = SEPARATOR_HEIGHT + COMPARTMENT_PADDING_Y;
|
|
7794
|
+
}
|
|
7749
7795
|
}
|
|
7750
|
-
const height = headerHeight + fieldsHeight + methodsHeight
|
|
7796
|
+
const height = headerHeight + fieldsHeight + methodsHeight;
|
|
7751
7797
|
return { width, height, headerHeight, fieldsHeight, methodsHeight };
|
|
7752
7798
|
}
|
|
7753
7799
|
function layoutClassDiagram(parsed) {
|
|
@@ -8001,17 +8047,15 @@ function renderClassDiagram(container, parsed, layout, palette, isDark, onClickI
|
|
|
8001
8047
|
const fields = node.members.filter((m) => !m.isMethod);
|
|
8002
8048
|
const methods = node.members.filter((m) => m.isMethod);
|
|
8003
8049
|
if (isEnum) {
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
memberY += MEMBER_LINE_HEIGHT2;
|
|
8010
|
-
}
|
|
8050
|
+
nodeG.append("line").attr("x1", -w / 2).attr("y1", yPos).attr("x2", w / 2).attr("y2", yPos).attr("stroke", stroke2).attr("stroke-width", 0.5).attr("stroke-opacity", 0.5);
|
|
8051
|
+
let memberY = yPos + COMPARTMENT_PADDING_Y2;
|
|
8052
|
+
for (const member of node.members) {
|
|
8053
|
+
nodeG.append("text").attr("x", -w / 2 + MEMBER_PADDING_X).attr("y", memberY + MEMBER_LINE_HEIGHT2 / 2).attr("dominant-baseline", "central").attr("fill", palette.text).attr("font-size", MEMBER_FONT_SIZE).text(member.name);
|
|
8054
|
+
memberY += MEMBER_LINE_HEIGHT2;
|
|
8011
8055
|
}
|
|
8012
8056
|
} else {
|
|
8057
|
+
nodeG.append("line").attr("x1", -w / 2).attr("y1", yPos).attr("x2", w / 2).attr("y2", yPos).attr("stroke", stroke2).attr("stroke-width", 0.5).attr("stroke-opacity", 0.5);
|
|
8013
8058
|
if (fields.length > 0) {
|
|
8014
|
-
nodeG.append("line").attr("x1", -w / 2).attr("y1", yPos).attr("x2", w / 2).attr("y2", yPos).attr("stroke", stroke2).attr("stroke-width", 0.5).attr("stroke-opacity", 0.5);
|
|
8015
8059
|
let memberY = yPos + COMPARTMENT_PADDING_Y2;
|
|
8016
8060
|
for (const field of fields) {
|
|
8017
8061
|
const vis = visibilitySymbol(field.visibility);
|
|
@@ -8024,10 +8068,10 @@ function renderClassDiagram(container, parsed, layout, palette, isDark, onClickI
|
|
|
8024
8068
|
textEl.text(text);
|
|
8025
8069
|
memberY += MEMBER_LINE_HEIGHT2;
|
|
8026
8070
|
}
|
|
8027
|
-
yPos += node.fieldsHeight;
|
|
8028
8071
|
}
|
|
8072
|
+
yPos += node.fieldsHeight;
|
|
8073
|
+
nodeG.append("line").attr("x1", -w / 2).attr("y1", yPos).attr("x2", w / 2).attr("y2", yPos).attr("stroke", stroke2).attr("stroke-width", 0.5).attr("stroke-opacity", 0.5);
|
|
8029
8074
|
if (methods.length > 0) {
|
|
8030
|
-
nodeG.append("line").attr("x1", -w / 2).attr("y1", yPos).attr("x2", w / 2).attr("y2", yPos).attr("stroke", stroke2).attr("stroke-width", 0.5).attr("stroke-opacity", 0.5);
|
|
8031
8075
|
let memberY = yPos + COMPARTMENT_PADDING_Y2;
|
|
8032
8076
|
for (const method of methods) {
|
|
8033
8077
|
const vis = visibilitySymbol(method.visibility);
|
|
@@ -12126,6 +12170,22 @@ function buildRenderSequence(messages) {
|
|
|
12126
12170
|
messageIndex: top.messageIndex
|
|
12127
12171
|
});
|
|
12128
12172
|
}
|
|
12173
|
+
if (msg.standaloneReturn) {
|
|
12174
|
+
for (let si = stack.length - 1; si >= 0; si--) {
|
|
12175
|
+
if (stack[si].from === msg.to && stack[si].to === msg.from) {
|
|
12176
|
+
stack.splice(si, 1);
|
|
12177
|
+
break;
|
|
12178
|
+
}
|
|
12179
|
+
}
|
|
12180
|
+
steps.push({
|
|
12181
|
+
type: "return",
|
|
12182
|
+
from: msg.from,
|
|
12183
|
+
to: msg.to,
|
|
12184
|
+
label: msg.label,
|
|
12185
|
+
messageIndex: mi
|
|
12186
|
+
});
|
|
12187
|
+
continue;
|
|
12188
|
+
}
|
|
12129
12189
|
steps.push({
|
|
12130
12190
|
type: "call",
|
|
12131
12191
|
from: msg.from,
|
|
@@ -13411,18 +13471,34 @@ function parseD3(content, palette) {
|
|
|
13411
13471
|
}
|
|
13412
13472
|
}
|
|
13413
13473
|
if (result.type === "quadrant") {
|
|
13414
|
-
const xAxisMatch = line7.match(/^x-axis\s*:\s*(
|
|
13474
|
+
const xAxisMatch = line7.match(/^x-axis\s*:\s*(.*)/i);
|
|
13415
13475
|
if (xAxisMatch) {
|
|
13416
|
-
const
|
|
13476
|
+
const val = xAxisMatch[1].trim();
|
|
13477
|
+
let parts;
|
|
13478
|
+
if (val) {
|
|
13479
|
+
parts = val.split(",").map((s) => s.trim());
|
|
13480
|
+
} else {
|
|
13481
|
+
const collected = collectIndentedValues(lines, i);
|
|
13482
|
+
i = collected.newIndex;
|
|
13483
|
+
parts = collected.values;
|
|
13484
|
+
}
|
|
13417
13485
|
if (parts.length >= 2) {
|
|
13418
13486
|
result.quadrantXAxis = [parts[0], parts[1]];
|
|
13419
13487
|
result.quadrantXAxisLineNumber = lineNumber;
|
|
13420
13488
|
}
|
|
13421
13489
|
continue;
|
|
13422
13490
|
}
|
|
13423
|
-
const yAxisMatch = line7.match(/^y-axis\s*:\s*(
|
|
13491
|
+
const yAxisMatch = line7.match(/^y-axis\s*:\s*(.*)/i);
|
|
13424
13492
|
if (yAxisMatch) {
|
|
13425
|
-
const
|
|
13493
|
+
const val = yAxisMatch[1].trim();
|
|
13494
|
+
let parts;
|
|
13495
|
+
if (val) {
|
|
13496
|
+
parts = val.split(",").map((s) => s.trim());
|
|
13497
|
+
} else {
|
|
13498
|
+
const collected = collectIndentedValues(lines, i);
|
|
13499
|
+
i = collected.newIndex;
|
|
13500
|
+
parts = collected.values;
|
|
13501
|
+
}
|
|
13426
13502
|
if (parts.length >= 2) {
|
|
13427
13503
|
result.quadrantYAxis = [parts[0], parts[1]];
|
|
13428
13504
|
result.quadrantYAxisLineNumber = lineNumber;
|
|
@@ -16233,6 +16309,7 @@ var init_d3 = __esm({
|
|
|
16233
16309
|
init_colors();
|
|
16234
16310
|
init_palettes();
|
|
16235
16311
|
init_diagnostics();
|
|
16312
|
+
init_parsing();
|
|
16236
16313
|
DEFAULT_CLOUD_OPTIONS = {
|
|
16237
16314
|
rotate: "none",
|
|
16238
16315
|
max: 0,
|