@diagrammo/dgmo 0.4.0 → 0.4.2

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.cjs CHANGED
@@ -1642,13 +1642,20 @@ function parseArrow(line7) {
1642
1642
  error: "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1643
1643
  };
1644
1644
  }
1645
+ if (RETURN_SYNC_LABELED_RE.test(line7) || RETURN_ASYNC_LABELED_RE.test(line7)) {
1646
+ const m = line7.match(RETURN_SYNC_LABELED_RE) ?? line7.match(RETURN_ASYNC_LABELED_RE);
1647
+ const from = m[3];
1648
+ const to = m[1];
1649
+ const label = m[2].trim();
1650
+ return {
1651
+ error: `Left-pointing arrows are no longer supported. Write '${from} -${label}-> ${to}' instead`
1652
+ };
1653
+ }
1645
1654
  const patterns = [
1646
- { re: RETURN_SYNC_LABELED_RE, async: false, isReturn: true },
1647
- { re: RETURN_ASYNC_LABELED_RE, async: true, isReturn: true },
1648
- { re: SYNC_LABELED_RE, async: false, isReturn: false },
1649
- { re: ASYNC_LABELED_RE, async: true, isReturn: false }
1655
+ { re: SYNC_LABELED_RE, async: false },
1656
+ { re: ASYNC_LABELED_RE, async: true }
1650
1657
  ];
1651
- for (const { re, async: isAsync, isReturn } of patterns) {
1658
+ for (const { re, async: isAsync } of patterns) {
1652
1659
  const m = line7.match(re);
1653
1660
  if (!m) continue;
1654
1661
  const label = m[2].trim();
@@ -1656,25 +1663,15 @@ function parseArrow(line7) {
1656
1663
  for (const arrow of ARROW_CHARS) {
1657
1664
  if (label.includes(arrow)) {
1658
1665
  return {
1659
- error: "Arrow characters (->, ~>, <-, <~) are not allowed inside labels"
1666
+ error: "Arrow characters (->, ~>) are not allowed inside labels"
1660
1667
  };
1661
1668
  }
1662
1669
  }
1663
- if (isReturn) {
1664
- return {
1665
- from: m[3],
1666
- to: m[1],
1667
- label,
1668
- async: isAsync,
1669
- isReturn: true
1670
- };
1671
- }
1672
1670
  return {
1673
1671
  from: m[1],
1674
1672
  to: m[3],
1675
1673
  label,
1676
- async: isAsync,
1677
- isReturn: false
1674
+ async: isAsync
1678
1675
  };
1679
1676
  }
1680
1677
  return null;
@@ -1689,7 +1686,7 @@ var init_arrows = __esm({
1689
1686
  RETURN_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~\s+(\S+)$/;
1690
1687
  BIDI_SYNC_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1691
1688
  BIDI_ASYNC_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1692
- ARROW_CHARS = ["->", "~>", "<-", "<~"];
1689
+ ARROW_CHARS = ["->", "~>"];
1693
1690
  }
1694
1691
  });
1695
1692
 
@@ -1939,15 +1936,14 @@ function parseSequenceDgmo(content) {
1939
1936
  }
1940
1937
  if (labeledArrow) {
1941
1938
  contentStarted = true;
1942
- const { from, to, label, async: isAsync, isReturn } = labeledArrow;
1939
+ const { from, to, label, async: isAsync } = labeledArrow;
1943
1940
  lastMsgFrom = from;
1944
1941
  const msg = {
1945
1942
  from,
1946
1943
  to,
1947
1944
  label,
1948
1945
  lineNumber,
1949
- ...isAsync ? { async: true } : {},
1950
- ...isReturn ? { standaloneReturn: true } : {}
1946
+ ...isAsync ? { async: true } : {}
1951
1947
  };
1952
1948
  result.messages.push(msg);
1953
1949
  currentContainer().push(msg);
@@ -2002,36 +1998,12 @@ function parseSequenceDgmo(content) {
2002
1998
  const bareReturnAsync = trimmed.match(/^(\S+)\s+<~\s+(\S+)$/);
2003
1999
  const bareReturn = bareReturnSync || bareReturnAsync;
2004
2000
  if (bareReturn) {
2005
- contentStarted = true;
2006
2001
  const to = bareReturn[1];
2007
2002
  const from = bareReturn[2];
2008
- lastMsgFrom = from;
2009
- const msg = {
2010
- from,
2011
- to,
2012
- label: "",
2003
+ pushError(
2013
2004
  lineNumber,
2014
- standaloneReturn: true,
2015
- ...bareReturnAsync ? { async: true } : {}
2016
- };
2017
- result.messages.push(msg);
2018
- currentContainer().push(msg);
2019
- if (!result.participants.some((p) => p.id === from)) {
2020
- result.participants.push({
2021
- id: from,
2022
- label: from,
2023
- type: inferParticipantType(from),
2024
- lineNumber
2025
- });
2026
- }
2027
- if (!result.participants.some((p) => p.id === to)) {
2028
- result.participants.push({
2029
- id: to,
2030
- label: to,
2031
- type: inferParticipantType(to),
2032
- lineNumber
2033
- });
2034
- }
2005
+ `Left-pointing arrows are no longer supported. Write '${from} -> ${to}' instead`
2006
+ );
2035
2007
  continue;
2036
2008
  }
2037
2009
  const bareCallSync = trimmed.match(/^(\S+)\s*->\s*(\S+)$/);
@@ -12035,22 +12007,6 @@ function buildRenderSequence(messages) {
12035
12007
  messageIndex: top.messageIndex
12036
12008
  });
12037
12009
  }
12038
- if (msg.standaloneReturn) {
12039
- for (let si = stack.length - 1; si >= 0; si--) {
12040
- if (stack[si].from === msg.to && stack[si].to === msg.from) {
12041
- stack.splice(si, 1);
12042
- break;
12043
- }
12044
- }
12045
- steps.push({
12046
- type: "return",
12047
- from: msg.from,
12048
- to: msg.to,
12049
- label: msg.label,
12050
- messageIndex: mi
12051
- });
12052
- continue;
12053
- }
12054
12010
  steps.push({
12055
12011
  type: "call",
12056
12012
  from: msg.from,