@diagrammo/dgmo 0.4.0 → 0.4.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
@@ -578,8 +578,6 @@ interface SequenceMessage {
578
578
  label: string;
579
579
  lineNumber: number;
580
580
  async?: boolean;
581
- /** Standalone return — the message itself IS a return (dashed arrow, no call). */
582
- standaloneReturn?: boolean;
583
581
  }
584
582
  /**
585
583
  * A conditional or loop block in the sequence diagram.
package/dist/index.d.ts CHANGED
@@ -578,8 +578,6 @@ interface SequenceMessage {
578
578
  label: string;
579
579
  lineNumber: number;
580
580
  async?: boolean;
581
- /** Standalone return — the message itself IS a return (dashed arrow, no call). */
582
- standaloneReturn?: boolean;
583
581
  }
584
582
  /**
585
583
  * A conditional or loop block in the sequence diagram.
package/dist/index.js CHANGED
@@ -1620,13 +1620,20 @@ function parseArrow(line7) {
1620
1620
  error: "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1621
1621
  };
1622
1622
  }
1623
+ if (RETURN_SYNC_LABELED_RE.test(line7) || RETURN_ASYNC_LABELED_RE.test(line7)) {
1624
+ const m = line7.match(RETURN_SYNC_LABELED_RE) ?? line7.match(RETURN_ASYNC_LABELED_RE);
1625
+ const from = m[3];
1626
+ const to = m[1];
1627
+ const label = m[2].trim();
1628
+ return {
1629
+ error: `Left-pointing arrows are no longer supported. Write '${from} -${label}-> ${to}' instead`
1630
+ };
1631
+ }
1623
1632
  const patterns = [
1624
- { re: RETURN_SYNC_LABELED_RE, async: false, isReturn: true },
1625
- { re: RETURN_ASYNC_LABELED_RE, async: true, isReturn: true },
1626
- { re: SYNC_LABELED_RE, async: false, isReturn: false },
1627
- { re: ASYNC_LABELED_RE, async: true, isReturn: false }
1633
+ { re: SYNC_LABELED_RE, async: false },
1634
+ { re: ASYNC_LABELED_RE, async: true }
1628
1635
  ];
1629
- for (const { re, async: isAsync, isReturn } of patterns) {
1636
+ for (const { re, async: isAsync } of patterns) {
1630
1637
  const m = line7.match(re);
1631
1638
  if (!m) continue;
1632
1639
  const label = m[2].trim();
@@ -1634,25 +1641,15 @@ function parseArrow(line7) {
1634
1641
  for (const arrow of ARROW_CHARS) {
1635
1642
  if (label.includes(arrow)) {
1636
1643
  return {
1637
- error: "Arrow characters (->, ~>, <-, <~) are not allowed inside labels"
1644
+ error: "Arrow characters (->, ~>) are not allowed inside labels"
1638
1645
  };
1639
1646
  }
1640
1647
  }
1641
- if (isReturn) {
1642
- return {
1643
- from: m[3],
1644
- to: m[1],
1645
- label,
1646
- async: isAsync,
1647
- isReturn: true
1648
- };
1649
- }
1650
1648
  return {
1651
1649
  from: m[1],
1652
1650
  to: m[3],
1653
1651
  label,
1654
- async: isAsync,
1655
- isReturn: false
1652
+ async: isAsync
1656
1653
  };
1657
1654
  }
1658
1655
  return null;
@@ -1667,7 +1664,7 @@ var init_arrows = __esm({
1667
1664
  RETURN_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~\s+(\S+)$/;
1668
1665
  BIDI_SYNC_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1669
1666
  BIDI_ASYNC_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1670
- ARROW_CHARS = ["->", "~>", "<-", "<~"];
1667
+ ARROW_CHARS = ["->", "~>"];
1671
1668
  }
1672
1669
  });
1673
1670
 
@@ -1917,15 +1914,14 @@ function parseSequenceDgmo(content) {
1917
1914
  }
1918
1915
  if (labeledArrow) {
1919
1916
  contentStarted = true;
1920
- const { from, to, label, async: isAsync, isReturn } = labeledArrow;
1917
+ const { from, to, label, async: isAsync } = labeledArrow;
1921
1918
  lastMsgFrom = from;
1922
1919
  const msg = {
1923
1920
  from,
1924
1921
  to,
1925
1922
  label,
1926
1923
  lineNumber,
1927
- ...isAsync ? { async: true } : {},
1928
- ...isReturn ? { standaloneReturn: true } : {}
1924
+ ...isAsync ? { async: true } : {}
1929
1925
  };
1930
1926
  result.messages.push(msg);
1931
1927
  currentContainer().push(msg);
@@ -1980,36 +1976,12 @@ function parseSequenceDgmo(content) {
1980
1976
  const bareReturnAsync = trimmed.match(/^(\S+)\s+<~\s+(\S+)$/);
1981
1977
  const bareReturn = bareReturnSync || bareReturnAsync;
1982
1978
  if (bareReturn) {
1983
- contentStarted = true;
1984
1979
  const to = bareReturn[1];
1985
1980
  const from = bareReturn[2];
1986
- lastMsgFrom = from;
1987
- const msg = {
1988
- from,
1989
- to,
1990
- label: "",
1981
+ pushError(
1991
1982
  lineNumber,
1992
- standaloneReturn: true,
1993
- ...bareReturnAsync ? { async: true } : {}
1994
- };
1995
- result.messages.push(msg);
1996
- currentContainer().push(msg);
1997
- if (!result.participants.some((p) => p.id === from)) {
1998
- result.participants.push({
1999
- id: from,
2000
- label: from,
2001
- type: inferParticipantType(from),
2002
- lineNumber
2003
- });
2004
- }
2005
- if (!result.participants.some((p) => p.id === to)) {
2006
- result.participants.push({
2007
- id: to,
2008
- label: to,
2009
- type: inferParticipantType(to),
2010
- lineNumber
2011
- });
2012
- }
1983
+ `Left-pointing arrows are no longer supported. Write '${from} -> ${to}' instead`
1984
+ );
2013
1985
  continue;
2014
1986
  }
2015
1987
  const bareCallSync = trimmed.match(/^(\S+)\s*->\s*(\S+)$/);
@@ -12014,22 +11986,6 @@ function buildRenderSequence(messages) {
12014
11986
  messageIndex: top.messageIndex
12015
11987
  });
12016
11988
  }
12017
- if (msg.standaloneReturn) {
12018
- for (let si = stack.length - 1; si >= 0; si--) {
12019
- if (stack[si].from === msg.to && stack[si].to === msg.from) {
12020
- stack.splice(si, 1);
12021
- break;
12022
- }
12023
- }
12024
- steps.push({
12025
- type: "return",
12026
- from: msg.from,
12027
- to: msg.to,
12028
- label: msg.label,
12029
- messageIndex: mi
12030
- });
12031
- continue;
12032
- }
12033
11989
  steps.push({
12034
11990
  type: "call",
12035
11991
  from: msg.from,