@diagrammo/dgmo 0.3.0 → 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/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);
@@ -3121,8 +3142,16 @@ function parseChart(content, palette) {
3121
3142
  continue;
3122
3143
  }
3123
3144
  if (key === "series") {
3124
- result.series = value;
3125
- const rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
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
+ }
3126
3155
  const names = [];
3127
3156
  const nameColors = [];
3128
3157
  for (const raw of rawNames) {
@@ -3201,6 +3230,7 @@ var init_chart = __esm({
3201
3230
  "use strict";
3202
3231
  init_colors();
3203
3232
  init_diagnostics();
3233
+ init_parsing();
3204
3234
  VALID_TYPES = /* @__PURE__ */ new Set([
3205
3235
  "bar",
3206
3236
  "line",
@@ -3277,8 +3307,16 @@ function parseEChart(content, palette) {
3277
3307
  continue;
3278
3308
  }
3279
3309
  if (key === "series") {
3280
- result.series = value;
3281
- const rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
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
+ }
3282
3320
  const names = [];
3283
3321
  const nameColors = [];
3284
3322
  for (const raw of rawNames) {
@@ -3314,11 +3352,23 @@ function parseEChart(content, palette) {
3314
3352
  continue;
3315
3353
  }
3316
3354
  if (key === "columns") {
3317
- result.columns = value.split(",").map((s) => s.trim());
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
+ }
3318
3362
  continue;
3319
3363
  }
3320
3364
  if (key === "rows") {
3321
- result.rows = value.split(",").map((s) => s.trim());
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
+ }
3322
3372
  continue;
3323
3373
  }
3324
3374
  if (key === "x") {
@@ -4633,6 +4683,7 @@ var init_echarts = __esm({
4633
4683
  init_palettes();
4634
4684
  init_chart();
4635
4685
  init_diagnostics();
4686
+ init_parsing();
4636
4687
  ECHART_EXPORT_WIDTH = 1200;
4637
4688
  ECHART_EXPORT_HEIGHT = 800;
4638
4689
  STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
@@ -12119,6 +12170,22 @@ function buildRenderSequence(messages) {
12119
12170
  messageIndex: top.messageIndex
12120
12171
  });
12121
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
+ }
12122
12189
  steps.push({
12123
12190
  type: "call",
12124
12191
  from: msg.from,
@@ -13404,18 +13471,34 @@ function parseD3(content, palette) {
13404
13471
  }
13405
13472
  }
13406
13473
  if (result.type === "quadrant") {
13407
- const xAxisMatch = line7.match(/^x-axis\s*:\s*(.+)/i);
13474
+ const xAxisMatch = line7.match(/^x-axis\s*:\s*(.*)/i);
13408
13475
  if (xAxisMatch) {
13409
- const parts = xAxisMatch[1].split(",").map((s) => s.trim());
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
+ }
13410
13485
  if (parts.length >= 2) {
13411
13486
  result.quadrantXAxis = [parts[0], parts[1]];
13412
13487
  result.quadrantXAxisLineNumber = lineNumber;
13413
13488
  }
13414
13489
  continue;
13415
13490
  }
13416
- const yAxisMatch = line7.match(/^y-axis\s*:\s*(.+)/i);
13491
+ const yAxisMatch = line7.match(/^y-axis\s*:\s*(.*)/i);
13417
13492
  if (yAxisMatch) {
13418
- const parts = yAxisMatch[1].split(",").map((s) => s.trim());
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
+ }
13419
13502
  if (parts.length >= 2) {
13420
13503
  result.quadrantYAxis = [parts[0], parts[1]];
13421
13504
  result.quadrantYAxisLineNumber = lineNumber;
@@ -16226,6 +16309,7 @@ var init_d3 = __esm({
16226
16309
  init_colors();
16227
16310
  init_palettes();
16228
16311
  init_diagnostics();
16312
+ init_parsing();
16229
16313
  DEFAULT_CLOUD_OPTIONS = {
16230
16314
  rotate: "none",
16231
16315
  max: 0,