@diagrammo/dgmo 0.8.22 → 0.8.25
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/commands/dgmo.md +60 -72
- package/dist/cli.cjs +123 -116
- package/dist/editor.cjs +3 -2
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.js +3 -2
- package/dist/editor.js.map +1 -1
- package/dist/highlight.cjs +3 -2
- package/dist/highlight.cjs.map +1 -1
- package/dist/highlight.js +3 -2
- package/dist/highlight.js.map +1 -1
- package/dist/index.cjs +1649 -442
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -23
- package/dist/index.d.ts +196 -23
- package/dist/index.js +1631 -440
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +677 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +267 -0
- package/dist/internal.d.ts +267 -0
- package/dist/internal.js +633 -0
- package/dist/internal.js.map +1 -0
- package/docs/guide/chart-area.md +17 -17
- package/docs/guide/chart-bar-stacked.md +12 -12
- package/docs/guide/chart-cycle.md +156 -0
- package/docs/guide/chart-doughnut.md +10 -10
- package/docs/guide/chart-funnel.md +9 -9
- package/docs/guide/chart-heatmap.md +10 -10
- package/docs/guide/chart-journey-map.md +179 -0
- package/docs/guide/chart-kanban.md +2 -0
- package/docs/guide/chart-line.md +19 -19
- package/docs/guide/chart-multi-line.md +16 -16
- package/docs/guide/chart-pie.md +11 -11
- package/docs/guide/chart-polar-area.md +10 -10
- package/docs/guide/chart-pyramid.md +111 -0
- package/docs/guide/chart-radar.md +9 -9
- package/docs/guide/chart-scatter.md +24 -27
- package/docs/guide/index.md +3 -3
- package/docs/guide/registry.json +5 -0
- package/docs/language-reference.md +108 -26
- package/fonts/Inter-Bold.ttf +0 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/LICENSE-Inter.txt +92 -0
- package/gallery/fixtures/bar-stacked.dgmo +12 -6
- package/gallery/fixtures/heatmap.dgmo +12 -6
- package/gallery/fixtures/multi-line.dgmo +11 -7
- package/gallery/fixtures/pyramid/dikw.dgmo +17 -0
- package/gallery/fixtures/pyramid/inverted-funnel.dgmo +16 -0
- package/gallery/fixtures/pyramid/minimal.dgmo +5 -0
- package/gallery/fixtures/quadrant.dgmo +8 -8
- package/gallery/fixtures/scatter.dgmo +12 -12
- package/package.json +14 -2
- package/src/boxes-and-lines/parser.ts +13 -2
- package/src/boxes-and-lines/renderer.ts +22 -13
- package/src/chart-type-scoring.ts +162 -0
- package/src/chart-types.ts +437 -0
- package/src/cli.ts +152 -101
- package/src/completion.ts +9 -48
- package/src/cycle/layout.ts +19 -28
- package/src/cycle/renderer.ts +59 -32
- package/src/cycle/types.ts +21 -0
- package/src/d3.ts +30 -3
- package/src/dgmo-router.ts +98 -73
- package/src/echarts.ts +1 -1
- package/src/editor/keywords.ts +3 -2
- package/src/fonts.ts +3 -2
- package/src/gantt/parser.ts +5 -1
- package/src/index.ts +37 -3
- package/src/infra/parser.ts +3 -3
- package/src/internal.ts +20 -0
- package/src/journey-map/layout.ts +7 -3
- package/src/journey-map/parser.ts +5 -1
- package/src/journey-map/renderer.ts +112 -47
- package/src/kanban/parser.ts +5 -1
- package/src/org/collapse.ts +82 -4
- package/src/org/parser.ts +1 -1
- package/src/org/renderer.ts +221 -4
- package/src/pyramid/parser.ts +172 -0
- package/src/pyramid/renderer.ts +684 -0
- package/src/pyramid/types.ts +28 -0
- package/src/render.ts +2 -8
- package/src/sequence/parser.ts +64 -22
- package/src/sequence/participant-inference.ts +0 -1
- package/src/sequence/renderer.ts +97 -265
- package/src/sharing.ts +0 -1
- package/src/sitemap/parser.ts +1 -1
- package/src/tech-radar/interactive.ts +54 -0
- package/src/utils/parsing.ts +1 -0
- package/src/utils/tag-groups.ts +35 -5
- package/src/wireframe/parser.ts +3 -1
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/utils/parsing.ts
|
|
34
|
+
function normalizeNumericToken(token) {
|
|
35
|
+
if (!token.includes(",") && !token.includes("_")) return null;
|
|
36
|
+
if (token.includes(",") && token.includes("_")) return null;
|
|
37
|
+
let sign = "";
|
|
38
|
+
let unsigned = token;
|
|
39
|
+
if (unsigned.startsWith("-")) {
|
|
40
|
+
sign = "-";
|
|
41
|
+
unsigned = unsigned.substring(1);
|
|
42
|
+
}
|
|
43
|
+
if (!unsigned) return null;
|
|
44
|
+
if (unsigned.includes(",")) {
|
|
45
|
+
if (/^\d{1,3}(,\d{3})+$/.test(unsigned))
|
|
46
|
+
return sign + unsigned.replace(/,/g, "");
|
|
47
|
+
if (/^\d{1,3}(,\d{3})+\.\d+$/.test(unsigned))
|
|
48
|
+
return sign + unsigned.replace(/,/g, "");
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (/^\d+(_\d+)+$/.test(unsigned)) return sign + unsigned.replace(/_/g, "");
|
|
52
|
+
if (/^\d+(_\d+)*\.\d+$/.test(unsigned) && unsigned.includes("_"))
|
|
53
|
+
return sign + unsigned.replace(/_/g, "");
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
var init_parsing = __esm({
|
|
57
|
+
"src/utils/parsing.ts"() {
|
|
58
|
+
"use strict";
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// src/chart.ts
|
|
63
|
+
function parseDataRowValues(line2, options) {
|
|
64
|
+
const segments = line2.split(",");
|
|
65
|
+
const normalized = [];
|
|
66
|
+
for (let i = 0; i < segments.length; i++) {
|
|
67
|
+
const seg = segments[i].trim();
|
|
68
|
+
if (i > 0 && /^\d{3}(\.\d+)?$/.test(seg) && !/^\s/.test(segments[i])) {
|
|
69
|
+
const prevSeg = normalized[normalized.length - 1].trimEnd();
|
|
70
|
+
if (/\d{1,3}$/.test(prevSeg)) {
|
|
71
|
+
const prevMatch = prevSeg.match(/(\d{1,3})$/);
|
|
72
|
+
if (prevMatch) {
|
|
73
|
+
normalized[normalized.length - 1] = prevSeg + seg;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
normalized.push(segments[i]);
|
|
79
|
+
}
|
|
80
|
+
const rebuilt = normalized.join(",");
|
|
81
|
+
const commaParts = rebuilt.split(",");
|
|
82
|
+
if (commaParts.length > 1) {
|
|
83
|
+
let numericCount = 0;
|
|
84
|
+
for (let j = commaParts.length - 1; j >= 0; j--) {
|
|
85
|
+
const part = normalizeNumericToken(commaParts[j].trim()) ?? commaParts[j].trim();
|
|
86
|
+
if (part && !isNaN(parseFloat(part)) && isFinite(Number(part))) {
|
|
87
|
+
numericCount++;
|
|
88
|
+
} else {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (numericCount > 0) {
|
|
93
|
+
const splitAt = commaParts.length - numericCount;
|
|
94
|
+
const extraValueParts = commaParts.slice(splitAt);
|
|
95
|
+
const firstPart = commaParts.slice(0, splitAt).join(",").trim();
|
|
96
|
+
const lastSpaceIdx = firstPart.lastIndexOf(" ");
|
|
97
|
+
if (lastSpaceIdx >= 0) {
|
|
98
|
+
const rawFirstVal = firstPart.substring(lastSpaceIdx + 1).trim();
|
|
99
|
+
const possibleFirstVal = normalizeNumericToken(rawFirstVal) ?? rawFirstVal;
|
|
100
|
+
if (possibleFirstVal && !isNaN(parseFloat(possibleFirstVal)) && isFinite(Number(possibleFirstVal))) {
|
|
101
|
+
const label2 = firstPart.substring(0, lastSpaceIdx).trim();
|
|
102
|
+
if (label2) {
|
|
103
|
+
const values = [parseFloat(possibleFirstVal)];
|
|
104
|
+
for (const p of extraValueParts) {
|
|
105
|
+
const normP = normalizeNumericToken(p.trim()) ?? p.trim();
|
|
106
|
+
values.push(parseFloat(normP));
|
|
107
|
+
}
|
|
108
|
+
return { label: label2, values };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const tokens = rebuilt.split(/\s+/);
|
|
115
|
+
if (tokens.length < 2) return null;
|
|
116
|
+
if (options?.multiValue) {
|
|
117
|
+
const limit = options.expectedValues ?? Infinity;
|
|
118
|
+
const values = [];
|
|
119
|
+
let idx = tokens.length - 1;
|
|
120
|
+
while (idx >= 1 && values.length < limit) {
|
|
121
|
+
const tok = tokens[idx];
|
|
122
|
+
const normTok = normalizeNumericToken(tok) ?? tok;
|
|
123
|
+
const num2 = parseFloat(normTok);
|
|
124
|
+
if (isNaN(num2) || !isFinite(Number(normTok))) break;
|
|
125
|
+
values.unshift(num2);
|
|
126
|
+
idx--;
|
|
127
|
+
}
|
|
128
|
+
if (values.length === 0) return null;
|
|
129
|
+
const label2 = tokens.slice(0, idx + 1).join(" ");
|
|
130
|
+
if (!label2) return null;
|
|
131
|
+
return { label: label2, values };
|
|
132
|
+
}
|
|
133
|
+
const lastToken = tokens[tokens.length - 1];
|
|
134
|
+
const normalizedLast = normalizeNumericToken(lastToken) ?? lastToken;
|
|
135
|
+
const num = parseFloat(normalizedLast);
|
|
136
|
+
if (isNaN(num) || !isFinite(Number(normalizedLast))) return null;
|
|
137
|
+
const label = tokens.slice(0, -1).join(" ");
|
|
138
|
+
if (!label) return null;
|
|
139
|
+
return { label, values: [num] };
|
|
140
|
+
}
|
|
141
|
+
var init_chart = __esm({
|
|
142
|
+
"src/chart.ts"() {
|
|
143
|
+
"use strict";
|
|
144
|
+
init_parsing();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// src/kanban/mutations.ts
|
|
149
|
+
function computeCardMove(content, parsed, cardId, targetColumnId, targetIndex) {
|
|
150
|
+
let sourceCard = null;
|
|
151
|
+
let sourceColumn = null;
|
|
152
|
+
for (const col of parsed.columns) {
|
|
153
|
+
for (const card of col.cards) {
|
|
154
|
+
if (card.id === cardId) {
|
|
155
|
+
sourceCard = card;
|
|
156
|
+
sourceColumn = col;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (sourceCard) break;
|
|
161
|
+
}
|
|
162
|
+
if (!sourceCard || !sourceColumn) return null;
|
|
163
|
+
const targetColumn = parsed.columns.find((c) => c.id === targetColumnId);
|
|
164
|
+
if (!targetColumn) return null;
|
|
165
|
+
const lines = content.split("\n");
|
|
166
|
+
const startIdx = sourceCard.lineNumber - 1;
|
|
167
|
+
const endIdx = sourceCard.endLineNumber - 1;
|
|
168
|
+
const cardLines = lines.slice(startIdx, endIdx + 1);
|
|
169
|
+
const withoutCard = [
|
|
170
|
+
...lines.slice(0, startIdx),
|
|
171
|
+
...lines.slice(endIdx + 1)
|
|
172
|
+
];
|
|
173
|
+
let insertIdx;
|
|
174
|
+
const removedCount = endIdx - startIdx + 1;
|
|
175
|
+
const adjustLine = (ln) => {
|
|
176
|
+
if (ln > endIdx + 1) return ln - removedCount;
|
|
177
|
+
return ln;
|
|
178
|
+
};
|
|
179
|
+
if (targetIndex === 0) {
|
|
180
|
+
const adjColLine = adjustLine(targetColumn.lineNumber);
|
|
181
|
+
insertIdx = adjColLine;
|
|
182
|
+
} else {
|
|
183
|
+
const targetCards = targetColumn.cards.filter((c) => c.id !== cardId);
|
|
184
|
+
const clampedIdx = Math.min(targetIndex, targetCards.length);
|
|
185
|
+
const precedingCard = targetCards[clampedIdx - 1];
|
|
186
|
+
if (!precedingCard) {
|
|
187
|
+
const adjColLine = adjustLine(targetColumn.lineNumber);
|
|
188
|
+
insertIdx = adjColLine;
|
|
189
|
+
} else {
|
|
190
|
+
const adjEndLine = adjustLine(precedingCard.endLineNumber);
|
|
191
|
+
insertIdx = adjEndLine;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const result = [
|
|
195
|
+
...withoutCard.slice(0, insertIdx),
|
|
196
|
+
...cardLines,
|
|
197
|
+
...withoutCard.slice(insertIdx)
|
|
198
|
+
];
|
|
199
|
+
return result.join("\n");
|
|
200
|
+
}
|
|
201
|
+
function computeCardArchive(content, parsed, cardId) {
|
|
202
|
+
let sourceCard = null;
|
|
203
|
+
for (const col of parsed.columns) {
|
|
204
|
+
for (const card of col.cards) {
|
|
205
|
+
if (card.id === cardId) {
|
|
206
|
+
sourceCard = card;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (sourceCard) break;
|
|
211
|
+
}
|
|
212
|
+
if (!sourceCard) return null;
|
|
213
|
+
const lines = content.split("\n");
|
|
214
|
+
const startIdx = sourceCard.lineNumber - 1;
|
|
215
|
+
const endIdx = sourceCard.endLineNumber - 1;
|
|
216
|
+
const cardLines = lines.slice(startIdx, endIdx + 1);
|
|
217
|
+
const withoutCard = [
|
|
218
|
+
...lines.slice(0, startIdx),
|
|
219
|
+
...lines.slice(endIdx + 1)
|
|
220
|
+
];
|
|
221
|
+
const archiveCol = parsed.columns.find(
|
|
222
|
+
(c) => c.name.toLowerCase() === ARCHIVE_COLUMN_NAME
|
|
223
|
+
);
|
|
224
|
+
if (archiveCol) {
|
|
225
|
+
const removedCount = endIdx - startIdx + 1;
|
|
226
|
+
let archiveEndLine = archiveCol.lineNumber;
|
|
227
|
+
if (archiveCol.cards.length > 0) {
|
|
228
|
+
const lastCard = archiveCol.cards[archiveCol.cards.length - 1];
|
|
229
|
+
archiveEndLine = lastCard.endLineNumber;
|
|
230
|
+
}
|
|
231
|
+
if (archiveEndLine > endIdx + 1) {
|
|
232
|
+
archiveEndLine -= removedCount;
|
|
233
|
+
}
|
|
234
|
+
const insertIdx = archiveEndLine;
|
|
235
|
+
return [
|
|
236
|
+
...withoutCard.slice(0, insertIdx),
|
|
237
|
+
...cardLines,
|
|
238
|
+
...withoutCard.slice(insertIdx)
|
|
239
|
+
].join("\n");
|
|
240
|
+
} else {
|
|
241
|
+
const trimmedEnd = withoutCard.length > 0 && withoutCard[withoutCard.length - 1].trim() === "" ? withoutCard : [...withoutCard, ""];
|
|
242
|
+
return [
|
|
243
|
+
...trimmedEnd,
|
|
244
|
+
"[Archive]",
|
|
245
|
+
...cardLines
|
|
246
|
+
].join("\n");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function isArchiveColumn(name) {
|
|
250
|
+
return name.toLowerCase() === ARCHIVE_COLUMN_NAME;
|
|
251
|
+
}
|
|
252
|
+
var ARCHIVE_COLUMN_NAME;
|
|
253
|
+
var init_mutations = __esm({
|
|
254
|
+
"src/kanban/mutations.ts"() {
|
|
255
|
+
"use strict";
|
|
256
|
+
ARCHIVE_COLUMN_NAME = "archive";
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// src/sequence/parser.ts
|
|
261
|
+
function isSequenceBlock(el) {
|
|
262
|
+
return "kind" in el && el.kind === "block";
|
|
263
|
+
}
|
|
264
|
+
function isSequenceSection(el) {
|
|
265
|
+
return "kind" in el && el.kind === "section";
|
|
266
|
+
}
|
|
267
|
+
function isSequenceNote(el) {
|
|
268
|
+
return "kind" in el && el.kind === "note";
|
|
269
|
+
}
|
|
270
|
+
var init_parser = __esm({
|
|
271
|
+
"src/sequence/parser.ts"() {
|
|
272
|
+
"use strict";
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// src/sequence/renderer.ts
|
|
277
|
+
function groupMessagesBySection(elements, messages) {
|
|
278
|
+
const groups = [];
|
|
279
|
+
let currentGroup = null;
|
|
280
|
+
const collectIndices = (els) => {
|
|
281
|
+
const indices = [];
|
|
282
|
+
for (const el of els) {
|
|
283
|
+
if (isSequenceBlock(el)) {
|
|
284
|
+
indices.push(
|
|
285
|
+
...collectIndices(el.children),
|
|
286
|
+
...collectIndices(el.elseChildren)
|
|
287
|
+
);
|
|
288
|
+
if (el.elseIfBranches) {
|
|
289
|
+
for (const branch of el.elseIfBranches) {
|
|
290
|
+
indices.push(...collectIndices(branch.children));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
} else if (isSequenceSection(el) || isSequenceNote(el)) {
|
|
294
|
+
continue;
|
|
295
|
+
} else {
|
|
296
|
+
const idx = messages.indexOf(el);
|
|
297
|
+
if (idx >= 0) indices.push(idx);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return indices;
|
|
301
|
+
};
|
|
302
|
+
for (const el of elements) {
|
|
303
|
+
if (isSequenceSection(el)) {
|
|
304
|
+
currentGroup = { section: el, messageIndices: [] };
|
|
305
|
+
groups.push(currentGroup);
|
|
306
|
+
} else if (currentGroup) {
|
|
307
|
+
if (isSequenceBlock(el)) {
|
|
308
|
+
currentGroup.messageIndices.push(...collectIndices([el]));
|
|
309
|
+
} else if (!isSequenceNote(el)) {
|
|
310
|
+
const idx = messages.indexOf(el);
|
|
311
|
+
if (idx >= 0) currentGroup.messageIndices.push(idx);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return groups;
|
|
316
|
+
}
|
|
317
|
+
function buildRenderSequence(messages) {
|
|
318
|
+
const steps = [];
|
|
319
|
+
const stack = [];
|
|
320
|
+
for (let mi = 0; mi < messages.length; mi++) {
|
|
321
|
+
const msg = messages[mi];
|
|
322
|
+
while (stack.length > 0) {
|
|
323
|
+
const top = stack[stack.length - 1];
|
|
324
|
+
if (top.to === msg.from) break;
|
|
325
|
+
stack.pop();
|
|
326
|
+
steps.push({
|
|
327
|
+
type: "return",
|
|
328
|
+
from: top.to,
|
|
329
|
+
to: top.from,
|
|
330
|
+
label: "",
|
|
331
|
+
messageIndex: top.messageIndex
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
steps.push({
|
|
335
|
+
type: "call",
|
|
336
|
+
from: msg.from,
|
|
337
|
+
to: msg.to,
|
|
338
|
+
label: msg.label,
|
|
339
|
+
messageIndex: mi,
|
|
340
|
+
...msg.async ? { async: true } : {}
|
|
341
|
+
});
|
|
342
|
+
if (msg.async) {
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (msg.from === msg.to) {
|
|
346
|
+
steps.push({
|
|
347
|
+
type: "return",
|
|
348
|
+
from: msg.to,
|
|
349
|
+
to: msg.from,
|
|
350
|
+
label: "",
|
|
351
|
+
messageIndex: mi
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
stack.push({
|
|
355
|
+
from: msg.from,
|
|
356
|
+
to: msg.to,
|
|
357
|
+
messageIndex: mi
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
while (stack.length > 0) {
|
|
362
|
+
const top = stack.pop();
|
|
363
|
+
steps.push({
|
|
364
|
+
type: "return",
|
|
365
|
+
from: top.to,
|
|
366
|
+
to: top.from,
|
|
367
|
+
label: "",
|
|
368
|
+
messageIndex: top.messageIndex
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return steps;
|
|
372
|
+
}
|
|
373
|
+
function computeActivations(steps) {
|
|
374
|
+
const activations = [];
|
|
375
|
+
const stacks = /* @__PURE__ */ new Map();
|
|
376
|
+
const getStack = (id) => {
|
|
377
|
+
if (!stacks.has(id)) stacks.set(id, []);
|
|
378
|
+
return stacks.get(id);
|
|
379
|
+
};
|
|
380
|
+
for (let i = 0; i < steps.length; i++) {
|
|
381
|
+
const step = steps[i];
|
|
382
|
+
if (step.type === "call") {
|
|
383
|
+
const s = getStack(step.to);
|
|
384
|
+
s.push(i);
|
|
385
|
+
} else {
|
|
386
|
+
const s = getStack(step.from);
|
|
387
|
+
if (s.length > 0) {
|
|
388
|
+
const startIdx = s.pop();
|
|
389
|
+
activations.push({
|
|
390
|
+
participantId: step.from,
|
|
391
|
+
startStep: startIdx,
|
|
392
|
+
endStep: i,
|
|
393
|
+
depth: s.length
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return activations;
|
|
399
|
+
}
|
|
400
|
+
function applyPositionOverrides(participants) {
|
|
401
|
+
if (!participants.some((p) => p.position !== void 0)) return participants;
|
|
402
|
+
const total = participants.length;
|
|
403
|
+
const positioned = [];
|
|
404
|
+
const unpositioned = [];
|
|
405
|
+
for (const p of participants) {
|
|
406
|
+
if (p.position !== void 0) {
|
|
407
|
+
let idx = p.position < 0 ? total + p.position : p.position;
|
|
408
|
+
idx = Math.max(0, Math.min(total - 1, idx));
|
|
409
|
+
positioned.push({ participant: p, index: idx });
|
|
410
|
+
} else {
|
|
411
|
+
unpositioned.push(p);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
positioned.sort((a, b) => a.index - b.index);
|
|
415
|
+
const result = new Array(total).fill(null);
|
|
416
|
+
const usedIndices = /* @__PURE__ */ new Set();
|
|
417
|
+
for (const { participant, index } of positioned) {
|
|
418
|
+
let idx = index;
|
|
419
|
+
if (usedIndices.has(idx)) {
|
|
420
|
+
for (let offset = 1; offset < total; offset++) {
|
|
421
|
+
if (idx + offset < total && !usedIndices.has(idx + offset)) {
|
|
422
|
+
idx = idx + offset;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
if (idx - offset >= 0 && !usedIndices.has(idx - offset)) {
|
|
426
|
+
idx = idx - offset;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
result[idx] = participant;
|
|
432
|
+
usedIndices.add(idx);
|
|
433
|
+
}
|
|
434
|
+
let uIdx = 0;
|
|
435
|
+
for (let i = 0; i < total; i++) {
|
|
436
|
+
if (result[i] === null) {
|
|
437
|
+
result[i] = unpositioned[uIdx++];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return result;
|
|
441
|
+
}
|
|
442
|
+
function applyGroupOrdering(participants, groups, messages = []) {
|
|
443
|
+
if (groups.length === 0) return participants;
|
|
444
|
+
const idToGroup = /* @__PURE__ */ new Map();
|
|
445
|
+
for (const group of groups) {
|
|
446
|
+
for (const id of group.participantIds) {
|
|
447
|
+
idToGroup.set(id, group);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const appearanceOrder = [];
|
|
451
|
+
const seen = /* @__PURE__ */ new Set();
|
|
452
|
+
for (const msg of messages) {
|
|
453
|
+
for (const id of [msg.from, msg.to]) {
|
|
454
|
+
if (!seen.has(id)) {
|
|
455
|
+
seen.add(id);
|
|
456
|
+
appearanceOrder.push(id);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
for (const p of participants) {
|
|
461
|
+
if (!seen.has(p.id)) {
|
|
462
|
+
seen.add(p.id);
|
|
463
|
+
appearanceOrder.push(p.id);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const result = [];
|
|
467
|
+
const placed = /* @__PURE__ */ new Set();
|
|
468
|
+
const placedGroups = /* @__PURE__ */ new Set();
|
|
469
|
+
for (const id of appearanceOrder) {
|
|
470
|
+
if (placed.has(id)) continue;
|
|
471
|
+
const group = idToGroup.get(id);
|
|
472
|
+
if (group && !placedGroups.has(group)) {
|
|
473
|
+
placedGroups.add(group);
|
|
474
|
+
for (const gid of group.participantIds) {
|
|
475
|
+
const p = participants.find((pp) => pp.id === gid);
|
|
476
|
+
if (p && !placed.has(gid)) {
|
|
477
|
+
result.push(p);
|
|
478
|
+
placed.add(gid);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
} else if (!group) {
|
|
482
|
+
const p = participants.find((pp) => pp.id === id);
|
|
483
|
+
if (p) {
|
|
484
|
+
result.push(p);
|
|
485
|
+
placed.add(id);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
function buildNoteMessageMap(elements) {
|
|
492
|
+
const map = /* @__PURE__ */ new Map();
|
|
493
|
+
let lastMessageLine = -1;
|
|
494
|
+
const walk = (els) => {
|
|
495
|
+
for (const el of els) {
|
|
496
|
+
if (isSequenceNote(el)) {
|
|
497
|
+
if (lastMessageLine >= 0) {
|
|
498
|
+
map.set(el.lineNumber, lastMessageLine);
|
|
499
|
+
}
|
|
500
|
+
} else if (isSequenceBlock(el)) {
|
|
501
|
+
walk(el.children);
|
|
502
|
+
if (el.elseIfBranches) {
|
|
503
|
+
for (const branch of el.elseIfBranches) {
|
|
504
|
+
walk(branch.children);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
walk(el.elseChildren);
|
|
508
|
+
} else if (!isSequenceSection(el)) {
|
|
509
|
+
const msg = el;
|
|
510
|
+
lastMessageLine = msg.lineNumber;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
walk(elements);
|
|
515
|
+
return map;
|
|
516
|
+
}
|
|
517
|
+
var d3Selection, PARTICIPANT_GAP, PARTICIPANT_BOX_WIDTH, NOTE_MAX_W, NOTE_FOLD, NOTE_PAD_H, NOTE_GAP, NOTE_CHAR_W, NOTE_CHARS_PER_LINE, ACTIVATION_WIDTH, NOTE_LANE_MAX, LABEL_CHAR_WIDTH, LABEL_MAX_CHARS;
|
|
518
|
+
var init_renderer = __esm({
|
|
519
|
+
"src/sequence/renderer.ts"() {
|
|
520
|
+
"use strict";
|
|
521
|
+
d3Selection = __toESM(require("d3-selection"), 1);
|
|
522
|
+
init_parser();
|
|
523
|
+
PARTICIPANT_GAP = 160;
|
|
524
|
+
PARTICIPANT_BOX_WIDTH = 120;
|
|
525
|
+
NOTE_MAX_W = 200;
|
|
526
|
+
NOTE_FOLD = 10;
|
|
527
|
+
NOTE_PAD_H = 8;
|
|
528
|
+
NOTE_GAP = 15;
|
|
529
|
+
NOTE_CHAR_W = 6;
|
|
530
|
+
NOTE_CHARS_PER_LINE = Math.floor(
|
|
531
|
+
(NOTE_MAX_W - NOTE_PAD_H * 2 - NOTE_FOLD) / NOTE_CHAR_W
|
|
532
|
+
);
|
|
533
|
+
ACTIVATION_WIDTH = 10;
|
|
534
|
+
NOTE_LANE_MAX = PARTICIPANT_GAP - ACTIVATION_WIDTH - NOTE_GAP;
|
|
535
|
+
LABEL_CHAR_WIDTH = 7.5;
|
|
536
|
+
LABEL_MAX_CHARS = Math.floor(
|
|
537
|
+
(PARTICIPANT_BOX_WIDTH - 10) / LABEL_CHAR_WIDTH
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// src/d3.ts
|
|
543
|
+
function orderArcNodes(links, order, groups) {
|
|
544
|
+
const nodeSet = /* @__PURE__ */ new Set();
|
|
545
|
+
for (const link of links) {
|
|
546
|
+
nodeSet.add(link.source);
|
|
547
|
+
nodeSet.add(link.target);
|
|
548
|
+
}
|
|
549
|
+
const allNodes = Array.from(nodeSet);
|
|
550
|
+
if (order === "name") {
|
|
551
|
+
return allNodes.slice().sort((a, b) => a.localeCompare(b));
|
|
552
|
+
}
|
|
553
|
+
if (order === "degree") {
|
|
554
|
+
const degree = /* @__PURE__ */ new Map();
|
|
555
|
+
for (const node of allNodes) degree.set(node, 0);
|
|
556
|
+
for (const link of links) {
|
|
557
|
+
degree.set(link.source, degree.get(link.source) + link.value);
|
|
558
|
+
degree.set(link.target, degree.get(link.target) + link.value);
|
|
559
|
+
}
|
|
560
|
+
return allNodes.slice().sort((a, b) => {
|
|
561
|
+
const diff = degree.get(b) - degree.get(a);
|
|
562
|
+
return diff !== 0 ? diff : a.localeCompare(b);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (order === "group") {
|
|
566
|
+
if (groups.length > 0) {
|
|
567
|
+
const ordered = [];
|
|
568
|
+
const placed = /* @__PURE__ */ new Set();
|
|
569
|
+
for (const group of groups) {
|
|
570
|
+
for (const node of group.nodes) {
|
|
571
|
+
if (!placed.has(node)) {
|
|
572
|
+
ordered.push(node);
|
|
573
|
+
placed.add(node);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
for (const node of allNodes) {
|
|
578
|
+
if (!placed.has(node)) {
|
|
579
|
+
ordered.push(node);
|
|
580
|
+
placed.add(node);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return ordered;
|
|
584
|
+
}
|
|
585
|
+
const adj = /* @__PURE__ */ new Map();
|
|
586
|
+
for (const node of allNodes) adj.set(node, /* @__PURE__ */ new Set());
|
|
587
|
+
for (const link of links) {
|
|
588
|
+
adj.get(link.source).add(link.target);
|
|
589
|
+
adj.get(link.target).add(link.source);
|
|
590
|
+
}
|
|
591
|
+
const degree = /* @__PURE__ */ new Map();
|
|
592
|
+
for (const node of allNodes) degree.set(node, 0);
|
|
593
|
+
for (const link of links) {
|
|
594
|
+
degree.set(link.source, degree.get(link.source) + link.value);
|
|
595
|
+
degree.set(link.target, degree.get(link.target) + link.value);
|
|
596
|
+
}
|
|
597
|
+
const visited = /* @__PURE__ */ new Set();
|
|
598
|
+
const components = [];
|
|
599
|
+
const remaining = new Set(allNodes);
|
|
600
|
+
while (remaining.size > 0) {
|
|
601
|
+
let root = "";
|
|
602
|
+
let maxDeg = -1;
|
|
603
|
+
for (const node of remaining) {
|
|
604
|
+
if (degree.get(node) > maxDeg) {
|
|
605
|
+
maxDeg = degree.get(node);
|
|
606
|
+
root = node;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const component = [];
|
|
610
|
+
const queue = [root];
|
|
611
|
+
visited.add(root);
|
|
612
|
+
remaining.delete(root);
|
|
613
|
+
while (queue.length > 0) {
|
|
614
|
+
const curr = queue.shift();
|
|
615
|
+
component.push(curr);
|
|
616
|
+
for (const neighbor of adj.get(curr)) {
|
|
617
|
+
if (!visited.has(neighbor)) {
|
|
618
|
+
visited.add(neighbor);
|
|
619
|
+
remaining.delete(neighbor);
|
|
620
|
+
queue.push(neighbor);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
components.push(component);
|
|
625
|
+
}
|
|
626
|
+
components.sort((a, b) => b.length - a.length);
|
|
627
|
+
return components.flat();
|
|
628
|
+
}
|
|
629
|
+
return allNodes;
|
|
630
|
+
}
|
|
631
|
+
var d3Scale, d3Selection2, d3Shape, d3Array, import_d3_cloud;
|
|
632
|
+
var init_d3 = __esm({
|
|
633
|
+
"src/d3.ts"() {
|
|
634
|
+
"use strict";
|
|
635
|
+
d3Scale = __toESM(require("d3-scale"), 1);
|
|
636
|
+
d3Selection2 = __toESM(require("d3-selection"), 1);
|
|
637
|
+
d3Shape = __toESM(require("d3-shape"), 1);
|
|
638
|
+
d3Array = __toESM(require("d3-array"), 1);
|
|
639
|
+
import_d3_cloud = __toESM(require("d3-cloud"), 1);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
// src/internal.ts
|
|
644
|
+
var internal_exports = {};
|
|
645
|
+
__export(internal_exports, {
|
|
646
|
+
applyGroupOrdering: () => applyGroupOrdering,
|
|
647
|
+
applyPositionOverrides: () => applyPositionOverrides,
|
|
648
|
+
buildNoteMessageMap: () => buildNoteMessageMap,
|
|
649
|
+
buildRenderSequence: () => buildRenderSequence,
|
|
650
|
+
computeActivations: () => computeActivations,
|
|
651
|
+
computeCardArchive: () => computeCardArchive,
|
|
652
|
+
computeCardMove: () => computeCardMove,
|
|
653
|
+
groupMessagesBySection: () => groupMessagesBySection,
|
|
654
|
+
isArchiveColumn: () => isArchiveColumn,
|
|
655
|
+
orderArcNodes: () => orderArcNodes,
|
|
656
|
+
parseDataRowValues: () => parseDataRowValues
|
|
657
|
+
});
|
|
658
|
+
module.exports = __toCommonJS(internal_exports);
|
|
659
|
+
init_chart();
|
|
660
|
+
init_mutations();
|
|
661
|
+
init_renderer();
|
|
662
|
+
init_d3();
|
|
663
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
664
|
+
0 && (module.exports = {
|
|
665
|
+
applyGroupOrdering,
|
|
666
|
+
applyPositionOverrides,
|
|
667
|
+
buildNoteMessageMap,
|
|
668
|
+
buildRenderSequence,
|
|
669
|
+
computeActivations,
|
|
670
|
+
computeCardArchive,
|
|
671
|
+
computeCardMove,
|
|
672
|
+
groupMessagesBySection,
|
|
673
|
+
isArchiveColumn,
|
|
674
|
+
orderArcNodes,
|
|
675
|
+
parseDataRowValues
|
|
676
|
+
});
|
|
677
|
+
//# sourceMappingURL=internal.cjs.map
|