@diagrammo/dgmo 0.2.26 → 0.2.27

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
@@ -5673,6 +5673,7 @@ function looksLikeInitiativeStatus(content) {
5673
5673
  const lines = content.split("\n");
5674
5674
  let hasArrow = false;
5675
5675
  let hasStatus = false;
5676
+ let hasIndentedArrow = false;
5676
5677
  for (const line7 of lines) {
5677
5678
  const trimmed = line7.trim();
5678
5679
  if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("//")) continue;
@@ -5680,13 +5681,15 @@ function looksLikeInitiativeStatus(content) {
5680
5681
  if (trimmed.match(/^title\s*:/i)) continue;
5681
5682
  if (trimmed.includes("->")) hasArrow = true;
5682
5683
  if (/\|\s*(done|wip|todo|na)\s*$/i.test(trimmed)) hasStatus = true;
5684
+ const isIndented = line7.length > 0 && line7 !== trimmed && /^\s/.test(line7);
5685
+ if (isIndented && trimmed.startsWith("->")) hasIndentedArrow = true;
5683
5686
  if (hasArrow && hasStatus) return true;
5684
5687
  }
5685
- return false;
5688
+ return hasIndentedArrow;
5686
5689
  }
5687
5690
  function parseStatus(raw, line7, diagnostics) {
5688
5691
  const trimmed = raw.trim().toLowerCase();
5689
- if (!trimmed) return null;
5692
+ if (!trimmed) return "na";
5690
5693
  if (VALID_STATUSES.includes(trimmed)) return trimmed;
5691
5694
  const hint = suggest(trimmed, VALID_STATUSES);
5692
5695
  const msg = `Unknown status "${raw.trim()}"${hint ? `. ${hint}` : ""}`;
@@ -5708,6 +5711,7 @@ function parseInitiativeStatus(content) {
5708
5711
  const lines = content.split("\n");
5709
5712
  const nodeLabels = /* @__PURE__ */ new Set();
5710
5713
  let currentGroup = null;
5714
+ let lastNodeLabel = null;
5711
5715
  for (let i = 0; i < lines.length; i++) {
5712
5716
  const lineNum = i + 1;
5713
5717
  const raw = lines[i];
@@ -5744,12 +5748,23 @@ function parseInitiativeStatus(content) {
5744
5748
  currentGroup = null;
5745
5749
  }
5746
5750
  if (trimmed.includes("->")) {
5747
- const edge = parseEdgeLine(trimmed, lineNum, result.diagnostics);
5751
+ let edgeText = trimmed;
5752
+ if (trimmed.startsWith("->")) {
5753
+ if (!lastNodeLabel) {
5754
+ result.diagnostics.push(
5755
+ makeDgmoError(lineNum, "Indented edge has no preceding node to use as source", "warning")
5756
+ );
5757
+ continue;
5758
+ }
5759
+ edgeText = `${lastNodeLabel} ${trimmed}`;
5760
+ }
5761
+ const edge = parseEdgeLine(edgeText, lineNum, result.diagnostics);
5748
5762
  if (edge) result.edges.push(edge);
5749
5763
  continue;
5750
5764
  }
5751
5765
  const node = parseNodeLine(trimmed, lineNum, result.diagnostics);
5752
5766
  if (node) {
5767
+ lastNodeLabel = node.label;
5753
5768
  if (nodeLabels.has(node.label)) {
5754
5769
  result.diagnostics.push(
5755
5770
  makeDgmoError(lineNum, `Duplicate node "${node.label}"`, "warning")
@@ -5772,7 +5787,7 @@ function parseInitiativeStatus(content) {
5772
5787
  makeDgmoError(edge.lineNumber, `Edge source "${edge.source}" is not a declared node`, "warning")
5773
5788
  );
5774
5789
  if (!result.nodes.some((n) => n.label === edge.source)) {
5775
- result.nodes.push({ label: edge.source, status: null, shape: inferParticipantType(edge.source), lineNumber: edge.lineNumber });
5790
+ result.nodes.push({ label: edge.source, status: "na", shape: inferParticipantType(edge.source), lineNumber: edge.lineNumber });
5776
5791
  nodeLabels.add(edge.source);
5777
5792
  }
5778
5793
  }
@@ -5781,7 +5796,7 @@ function parseInitiativeStatus(content) {
5781
5796
  makeDgmoError(edge.lineNumber, `Edge target "${edge.target}" is not a declared node`, "warning")
5782
5797
  );
5783
5798
  if (!result.nodes.some((n) => n.label === edge.target)) {
5784
- result.nodes.push({ label: edge.target, status: null, shape: inferParticipantType(edge.target), lineNumber: edge.lineNumber });
5799
+ result.nodes.push({ label: edge.target, status: "na", shape: inferParticipantType(edge.target), lineNumber: edge.lineNumber });
5785
5800
  nodeLabels.add(edge.target);
5786
5801
  }
5787
5802
  }
@@ -5797,7 +5812,7 @@ function parseNodeLine(trimmed, lineNum, diagnostics) {
5797
5812
  const status = parseStatus(statusRaw, lineNum, diagnostics);
5798
5813
  return { label, status, shape: inferParticipantType(label), lineNumber: lineNum };
5799
5814
  }
5800
- return { label: trimmed, status: null, shape: inferParticipantType(trimmed), lineNumber: lineNum };
5815
+ return { label: trimmed, status: "na", shape: inferParticipantType(trimmed), lineNumber: lineNum };
5801
5816
  }
5802
5817
  function parseEdgeLine(trimmed, lineNum, diagnostics) {
5803
5818
  const arrowIdx = trimmed.indexOf("->");
@@ -5808,7 +5823,7 @@ function parseEdgeLine(trimmed, lineNum, diagnostics) {
5808
5823
  diagnostics.push(makeDgmoError(lineNum, "Edge is missing source or target"));
5809
5824
  return null;
5810
5825
  }
5811
- let status = null;
5826
+ let status = "na";
5812
5827
  const lastPipe = rest.lastIndexOf("|");
5813
5828
  if (lastPipe >= 0) {
5814
5829
  const statusRaw = rest.slice(lastPipe + 1).trim();