@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.js CHANGED
@@ -5651,6 +5651,7 @@ function looksLikeInitiativeStatus(content) {
5651
5651
  const lines = content.split("\n");
5652
5652
  let hasArrow = false;
5653
5653
  let hasStatus = false;
5654
+ let hasIndentedArrow = false;
5654
5655
  for (const line7 of lines) {
5655
5656
  const trimmed = line7.trim();
5656
5657
  if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("//")) continue;
@@ -5658,13 +5659,15 @@ function looksLikeInitiativeStatus(content) {
5658
5659
  if (trimmed.match(/^title\s*:/i)) continue;
5659
5660
  if (trimmed.includes("->")) hasArrow = true;
5660
5661
  if (/\|\s*(done|wip|todo|na)\s*$/i.test(trimmed)) hasStatus = true;
5662
+ const isIndented = line7.length > 0 && line7 !== trimmed && /^\s/.test(line7);
5663
+ if (isIndented && trimmed.startsWith("->")) hasIndentedArrow = true;
5661
5664
  if (hasArrow && hasStatus) return true;
5662
5665
  }
5663
- return false;
5666
+ return hasIndentedArrow;
5664
5667
  }
5665
5668
  function parseStatus(raw, line7, diagnostics) {
5666
5669
  const trimmed = raw.trim().toLowerCase();
5667
- if (!trimmed) return null;
5670
+ if (!trimmed) return "na";
5668
5671
  if (VALID_STATUSES.includes(trimmed)) return trimmed;
5669
5672
  const hint = suggest(trimmed, VALID_STATUSES);
5670
5673
  const msg = `Unknown status "${raw.trim()}"${hint ? `. ${hint}` : ""}`;
@@ -5686,6 +5689,7 @@ function parseInitiativeStatus(content) {
5686
5689
  const lines = content.split("\n");
5687
5690
  const nodeLabels = /* @__PURE__ */ new Set();
5688
5691
  let currentGroup = null;
5692
+ let lastNodeLabel = null;
5689
5693
  for (let i = 0; i < lines.length; i++) {
5690
5694
  const lineNum = i + 1;
5691
5695
  const raw = lines[i];
@@ -5722,12 +5726,23 @@ function parseInitiativeStatus(content) {
5722
5726
  currentGroup = null;
5723
5727
  }
5724
5728
  if (trimmed.includes("->")) {
5725
- const edge = parseEdgeLine(trimmed, lineNum, result.diagnostics);
5729
+ let edgeText = trimmed;
5730
+ if (trimmed.startsWith("->")) {
5731
+ if (!lastNodeLabel) {
5732
+ result.diagnostics.push(
5733
+ makeDgmoError(lineNum, "Indented edge has no preceding node to use as source", "warning")
5734
+ );
5735
+ continue;
5736
+ }
5737
+ edgeText = `${lastNodeLabel} ${trimmed}`;
5738
+ }
5739
+ const edge = parseEdgeLine(edgeText, lineNum, result.diagnostics);
5726
5740
  if (edge) result.edges.push(edge);
5727
5741
  continue;
5728
5742
  }
5729
5743
  const node = parseNodeLine(trimmed, lineNum, result.diagnostics);
5730
5744
  if (node) {
5745
+ lastNodeLabel = node.label;
5731
5746
  if (nodeLabels.has(node.label)) {
5732
5747
  result.diagnostics.push(
5733
5748
  makeDgmoError(lineNum, `Duplicate node "${node.label}"`, "warning")
@@ -5750,7 +5765,7 @@ function parseInitiativeStatus(content) {
5750
5765
  makeDgmoError(edge.lineNumber, `Edge source "${edge.source}" is not a declared node`, "warning")
5751
5766
  );
5752
5767
  if (!result.nodes.some((n) => n.label === edge.source)) {
5753
- result.nodes.push({ label: edge.source, status: null, shape: inferParticipantType(edge.source), lineNumber: edge.lineNumber });
5768
+ result.nodes.push({ label: edge.source, status: "na", shape: inferParticipantType(edge.source), lineNumber: edge.lineNumber });
5754
5769
  nodeLabels.add(edge.source);
5755
5770
  }
5756
5771
  }
@@ -5759,7 +5774,7 @@ function parseInitiativeStatus(content) {
5759
5774
  makeDgmoError(edge.lineNumber, `Edge target "${edge.target}" is not a declared node`, "warning")
5760
5775
  );
5761
5776
  if (!result.nodes.some((n) => n.label === edge.target)) {
5762
- result.nodes.push({ label: edge.target, status: null, shape: inferParticipantType(edge.target), lineNumber: edge.lineNumber });
5777
+ result.nodes.push({ label: edge.target, status: "na", shape: inferParticipantType(edge.target), lineNumber: edge.lineNumber });
5763
5778
  nodeLabels.add(edge.target);
5764
5779
  }
5765
5780
  }
@@ -5775,7 +5790,7 @@ function parseNodeLine(trimmed, lineNum, diagnostics) {
5775
5790
  const status = parseStatus(statusRaw, lineNum, diagnostics);
5776
5791
  return { label, status, shape: inferParticipantType(label), lineNumber: lineNum };
5777
5792
  }
5778
- return { label: trimmed, status: null, shape: inferParticipantType(trimmed), lineNumber: lineNum };
5793
+ return { label: trimmed, status: "na", shape: inferParticipantType(trimmed), lineNumber: lineNum };
5779
5794
  }
5780
5795
  function parseEdgeLine(trimmed, lineNum, diagnostics) {
5781
5796
  const arrowIdx = trimmed.indexOf("->");
@@ -5786,7 +5801,7 @@ function parseEdgeLine(trimmed, lineNum, diagnostics) {
5786
5801
  diagnostics.push(makeDgmoError(lineNum, "Edge is missing source or target"));
5787
5802
  return null;
5788
5803
  }
5789
- let status = null;
5804
+ let status = "na";
5790
5805
  const lastPipe = rest.lastIndexOf("|");
5791
5806
  if (lastPipe >= 0) {
5792
5807
  const statusRaw = rest.slice(lastPipe + 1).trim();