@yorz/cli 0.1.4 → 0.1.5

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.
Files changed (138) hide show
  1. package/dist/cli/index.js +133 -53
  2. package/dist/gui/assets/{abnfDiagram-VRR7QNED-BlILeZZA.js → abnfDiagram-VRR7QNED-BjiKWU_r.js} +1 -1
  3. package/dist/gui/assets/{arc-C-xJpbjF.js → arc--ZszoeC5.js} +1 -1
  4. package/dist/gui/assets/{architectureDiagram-ZJ3FMSHR-QdzNii0b.js → architectureDiagram-ZJ3FMSHR-D8beCiJM.js} +1 -1
  5. package/dist/gui/assets/{blockDiagram-677ZJIJ3-BQTAKTET.js → blockDiagram-677ZJIJ3-XTjBv4Yl.js} +1 -1
  6. package/dist/gui/assets/{c4Diagram-LMCZKHZV-YRh3fqeb.js → c4Diagram-LMCZKHZV-B8mRAP6M.js} +1 -1
  7. package/dist/gui/assets/channel-DSEvjkHE.js +1 -0
  8. package/dist/gui/assets/{chunk-2Q5K7J3B-Bgu-eeCS.js → chunk-2Q5K7J3B-yiwKrUMh.js} +1 -1
  9. package/dist/gui/assets/{chunk-32BRIVSS-DTLd8wsP.js → chunk-32BRIVSS-BKUpEqmm.js} +1 -1
  10. package/dist/gui/assets/{chunk-5VM5RSS4-Cct8HJoz.js → chunk-5VM5RSS4-DbsGyMz5.js} +1 -1
  11. package/dist/gui/assets/{chunk-EX3LRPZG-DBgaA_1N.js → chunk-EX3LRPZG-DTBuQkne.js} +1 -1
  12. package/dist/gui/assets/{chunk-JWPE2WC7-DELoF8bV.js → chunk-JWPE2WC7-Durur7_4.js} +1 -1
  13. package/dist/gui/assets/{chunk-MOJQB5TN-Du6uREYs.js → chunk-MOJQB5TN-DXNE2VJB.js} +1 -1
  14. package/dist/gui/assets/{chunk-RYQCIY6F-CxO6cQdM.js → chunk-RYQCIY6F-HY8qhnee.js} +1 -1
  15. package/dist/gui/assets/{chunk-V7JOEXUC-BiILBcGA.js → chunk-V7JOEXUC-BXRxPy5M.js} +1 -1
  16. package/dist/gui/assets/{chunk-VR4S4FIN-BfY2RvG4.js → chunk-VR4S4FIN-Ws4fVn18.js} +1 -1
  17. package/dist/gui/assets/{chunk-XXDRQBXY-DmsZw6tB.js → chunk-XXDRQBXY-CwHBGyO1.js} +1 -1
  18. package/dist/gui/assets/classDiagram-OUVF2IWQ-BN1qwPdD.js +1 -0
  19. package/dist/gui/assets/classDiagram-v2-EOCWNBFH-BN1qwPdD.js +1 -0
  20. package/dist/gui/assets/{cose-bilkent-JH36ORCC-gX-8DSxS.js → cose-bilkent-JH36ORCC-C3oDctXM.js} +1 -1
  21. package/dist/gui/assets/{cynefin-VYW2F7L2-vOfRo7cL.js → cynefin-VYW2F7L2-BjremdIM.js} +1 -1
  22. package/dist/gui/assets/{cynefinDiagram-TSTJHNR4-Dv66a7Rh.js → cynefinDiagram-TSTJHNR4-Cwe2fD65.js} +1 -1
  23. package/dist/gui/assets/{dagre-VKFMJZFB-Rk64dDvT.js → dagre-VKFMJZFB-Bx2kzeqs.js} +1 -1
  24. package/dist/gui/assets/{diagram-FQU43EPY-CyW3IjmQ.js → diagram-FQU43EPY-BVyLKNdq.js} +1 -1
  25. package/dist/gui/assets/{diagram-G47NLZAW-Caav47lW.js → diagram-G47NLZAW-DicBAwcf.js} +1 -1
  26. package/dist/gui/assets/{diagram-NH7WQ7WH-_X3ihqNf.js → diagram-NH7WQ7WH-BbRrvaYb.js} +1 -1
  27. package/dist/gui/assets/{diagram-OA4YK3LP-CjbverOE.js → diagram-OA4YK3LP-C2YIUXV5.js} +1 -1
  28. package/dist/gui/assets/{diagram-WEI45ONY-B93ZeTtT.js → diagram-WEI45ONY-DJHPHFaZ.js} +1 -1
  29. package/dist/gui/assets/{ebnfDiagram-CCIWWBDH-CdDt4bWx.js → ebnfDiagram-CCIWWBDH-DtDW0rR6.js} +1 -1
  30. package/dist/gui/assets/{erDiagram-Q63AITRT-Bypq-rvj.js → erDiagram-Q63AITRT-C5CAH1UZ.js} +1 -1
  31. package/dist/gui/assets/{flowDiagram-23GEKE2U-b-l8_7KP.js → flowDiagram-23GEKE2U-DA2WblHa.js} +1 -1
  32. package/dist/gui/assets/{ganttDiagram-NO4QXBWP-BeZFHLhX.js → ganttDiagram-NO4QXBWP-TMRYyAbG.js} +1 -1
  33. package/dist/gui/assets/{gitGraphDiagram-IHSO6WYX-C0siPGLA.js → gitGraphDiagram-IHSO6WYX-Ci-GVNac.js} +1 -1
  34. package/dist/gui/assets/index-Bq3A8DU2.js +21 -0
  35. package/dist/gui/assets/{infoDiagram-FWYZ7A6U-Bk8DNKgG.js → infoDiagram-FWYZ7A6U-BV4Ye9h-.js} +1 -1
  36. package/dist/gui/assets/{ishikawaDiagram-FXEZZL3T-DyS4wmJu.js → ishikawaDiagram-FXEZZL3T-CLBTOnXf.js} +1 -1
  37. package/dist/gui/assets/{journeyDiagram-5HDEW3XC-4jUY7Bzi.js → journeyDiagram-5HDEW3XC-BINYoOlq.js} +1 -1
  38. package/dist/gui/assets/{kanban-definition-HUTT4EX6-BRiI4KbM.js → kanban-definition-HUTT4EX6-Bvoywhuo.js} +1 -1
  39. package/dist/gui/assets/{linear-C5JkbjyJ.js → linear-CldLHplp.js} +1 -1
  40. package/dist/gui/assets/{mermaid.core-ImB_5gdE.js → mermaid.core-1Uynhu-S.js} +4 -4
  41. package/dist/gui/assets/{mindmap-definition-LN4V7U3C-9_Awmd2W.js → mindmap-definition-LN4V7U3C-Sv5B_zGg.js} +1 -1
  42. package/dist/gui/assets/{pegDiagram-2B236MQR-DF_vIYzp.js → pegDiagram-2B236MQR-CyYAur_9.js} +1 -1
  43. package/dist/gui/assets/{pieDiagram-ENE6RG2P-3TPwXSjQ.js → pieDiagram-ENE6RG2P-D3P7lu31.js} +1 -1
  44. package/dist/gui/assets/{quadrantDiagram-ABIIQ3AL-jzJ30mNi.js → quadrantDiagram-ABIIQ3AL-zmQrhKVf.js} +1 -1
  45. package/dist/gui/assets/{railroadDiagram-RFXS5EU6-B-29q3CI.js → railroadDiagram-RFXS5EU6-D5HlXQ4M.js} +1 -1
  46. package/dist/gui/assets/{requirementDiagram-TGXJPOKE-BanWpS6g.js → requirementDiagram-TGXJPOKE-BJcv5tpR.js} +1 -1
  47. package/dist/gui/assets/{sankeyDiagram-HTMAVEWB-B_sxc9IV.js → sankeyDiagram-HTMAVEWB-9R97Q-65.js} +1 -1
  48. package/dist/gui/assets/{sequenceDiagram-DBY2YBRQ-BNVav9DA.js → sequenceDiagram-DBY2YBRQ-D6v2e_UA.js} +1 -1
  49. package/dist/gui/assets/{sizeCapture-X5ZJPWSS-DbaiKjno.js → sizeCapture-X5ZJPWSS-5Ee75AoR.js} +1 -1
  50. package/dist/gui/assets/{stateDiagram-2N3HPSRC-jU5WBm6c.js → stateDiagram-2N3HPSRC-CiFKPVFd.js} +1 -1
  51. package/dist/gui/assets/stateDiagram-v2-6OUMAXLB-XeM3QPuf.js +1 -0
  52. package/dist/gui/assets/{swimlanes-5IMT3BWC-Dcmb64x2.js → swimlanes-5IMT3BWC-DejeKz32.js} +2 -2
  53. package/dist/gui/assets/swimlanesDiagram-G3AALYLV-BaUP5W6u.js +8 -0
  54. package/dist/gui/assets/{timeline-definition-FHXFAJF6-COm9ow7j.js → timeline-definition-FHXFAJF6-CpW-bina.js} +1 -1
  55. package/dist/gui/assets/{vennDiagram-L72KCM5P-DliDuTVY.js → vennDiagram-L72KCM5P-DFEDh4dV.js} +1 -1
  56. package/dist/gui/assets/{wardleyDiagram-EHGQE667-C2O_2cpw.js → wardleyDiagram-EHGQE667-B4Blcc-a.js} +1 -1
  57. package/dist/gui/assets/{xychartDiagram-FW5EYKEG-Ldmt9hoc.js → xychartDiagram-FW5EYKEG-D9idxadT.js} +1 -1
  58. package/dist/gui/index.html +1 -1
  59. package/package.json +1 -1
  60. package/dist/_commonjsHelpers-DyI1JsEH.js +0 -34
  61. package/dist/abnfDiagram-VRR7QNED-UQS77aUi.js +0 -119
  62. package/dist/api-DrYc_Ds_.js +0 -129852
  63. package/dist/arc-B1cAL3U1.js +0 -132
  64. package/dist/architectureDiagram-ZJ3FMSHR-CfWOhs-q.js +0 -8816
  65. package/dist/blockDiagram-677ZJIJ3-CLOAAFZa.js +0 -3796
  66. package/dist/c4Diagram-LMCZKHZV-BGdELGkb.js +0 -2483
  67. package/dist/certs-BeimSwB3.js +0 -14071
  68. package/dist/certs-C4t5lAmJ.js +0 -14071
  69. package/dist/certs-CLLngjpY.js +0 -14071
  70. package/dist/certs-D3fTB-0_.js +0 -14071
  71. package/dist/channel-_gQD3mZ8.js +0 -8
  72. package/dist/chunk-2Q5K7J3B-DIJkMPWD.js +0 -20
  73. package/dist/chunk-32BRIVSS-CIQb7-9I.js +0 -117
  74. package/dist/chunk-5VM5RSS4-DmlAsh6o.js +0 -20
  75. package/dist/chunk-EX3LRPZG-BEXyn5R-.js +0 -1989
  76. package/dist/chunk-JWPE2WC7-XiIefccF.js +0 -17
  77. package/dist/chunk-MOJQB5TN-CC5OBDWw.js +0 -861
  78. package/dist/chunk-RYQCIY6F-DQacsGpB.js +0 -475
  79. package/dist/chunk-V7JOEXUC-TLRsIUvf.js +0 -2027
  80. package/dist/chunk-VR4S4FIN-9AfN7RDF.js +0 -25
  81. package/dist/chunk-XXDRQBXY-DhWucSRr.js +0 -14
  82. package/dist/classDiagram-OUVF2IWQ-CN55rRkB.js +0 -20
  83. package/dist/classDiagram-v2-EOCWNBFH-CN55rRkB.js +0 -20
  84. package/dist/cose-bilkent-JH36ORCC-8uGYe6_d.js +0 -4944
  85. package/dist/cynefin-VYW2F7L2-BwTeE-TI.js +0 -32061
  86. package/dist/cynefinDiagram-TSTJHNR4-DM7ixE-v.js +0 -454
  87. package/dist/cytoscape.esm-BTopYfIb.js +0 -30347
  88. package/dist/dagre-VKFMJZFB-blEDoYen.js +0 -522
  89. package/dist/defaultLocale-wHUL1xE2.js +0 -207
  90. package/dist/diagram-FQU43EPY-MEZlmmdi.js +0 -633
  91. package/dist/diagram-G47NLZAW-DZOZvHqp.js +0 -857
  92. package/dist/diagram-NH7WQ7WH-ChpmPbZz.js +0 -213
  93. package/dist/diagram-OA4YK3LP-oy4yvrnL.js +0 -489
  94. package/dist/diagram-WEI45ONY-B3nx1cYt.js +0 -305
  95. package/dist/ebnfDiagram-CCIWWBDH-BASj7BoO.js +0 -139
  96. package/dist/erDiagram-Q63AITRT-lujHq-S9.js +0 -1239
  97. package/dist/flowDiagram-23GEKE2U-BdsAVPgU.js +0 -2349
  98. package/dist/ganttDiagram-NO4QXBWP-DUUP4lsu.js +0 -3733
  99. package/dist/gitGraphDiagram-IHSO6WYX-BdIPAtb0.js +0 -1374
  100. package/dist/graph-CE8jV7cI.js +0 -2043
  101. package/dist/gui/assets/channel-DGoXAS0B.js +0 -1
  102. package/dist/gui/assets/classDiagram-OUVF2IWQ-B4zeZ0PC.js +0 -1
  103. package/dist/gui/assets/classDiagram-v2-EOCWNBFH-B4zeZ0PC.js +0 -1
  104. package/dist/gui/assets/index-DKVgyltQ.js +0 -21
  105. package/dist/gui/assets/stateDiagram-v2-6OUMAXLB-GXq_r-DG.js +0 -1
  106. package/dist/gui/assets/swimlanesDiagram-G3AALYLV-DDE-INgq.js +0 -8
  107. package/dist/index--GoVvfUP.js +0 -5447
  108. package/dist/index-3-WDiDAh.js +0 -5466
  109. package/dist/index-CHBXZAxg.js +0 -5460
  110. package/dist/index-DeCq8xn7.js +0 -5460
  111. package/dist/infoDiagram-FWYZ7A6U-D9wo93kg.js +0 -32
  112. package/dist/init-DDGa2CQM.js +0 -17
  113. package/dist/ishikawaDiagram-FXEZZL3T-DZh3_kt2.js +0 -968
  114. package/dist/journeyDiagram-5HDEW3XC-C8RWHIn0.js +0 -1256
  115. package/dist/kanban-definition-HUTT4EX6-B7qQtB5a.js +0 -1053
  116. package/dist/katex-WjDlQEfU.js +0 -14500
  117. package/dist/layout-DQAYh_L7.js +0 -2360
  118. package/dist/linear-C_kZRZXS.js +0 -341
  119. package/dist/map-BElV7BMC.js +0 -299
  120. package/dist/mermaid.core-Dy_tFRs7.js +0 -26495
  121. package/dist/mindmap-definition-LN4V7U3C-BzHCd5Ab.js +0 -1181
  122. package/dist/ordinal-C2kkg180.js +0 -77
  123. package/dist/pegDiagram-2B236MQR-B046bQWM.js +0 -127
  124. package/dist/pieDiagram-ENE6RG2P-B5_W2CZy.js +0 -316
  125. package/dist/quadrantDiagram-ABIIQ3AL-Bbpt496h.js +0 -1342
  126. package/dist/railroadDiagram-RFXS5EU6-10XIH3X0.js +0 -93
  127. package/dist/requirementDiagram-TGXJPOKE-Dt1QyccY.js +0 -1205
  128. package/dist/sankeyDiagram-HTMAVEWB-CnqRAq7M.js +0 -1274
  129. package/dist/sequenceDiagram-DBY2YBRQ-DtJLSXoz.js +0 -4515
  130. package/dist/sizeCapture-X5ZJPWSS-DUl5ZEo3.js +0 -63
  131. package/dist/stateDiagram-2N3HPSRC-b-qzcVNj.js +0 -449
  132. package/dist/stateDiagram-v2-6OUMAXLB-KjDlRfc7.js +0 -20
  133. package/dist/swimlanes-5IMT3BWC-CAjGnQLa.js +0 -8553
  134. package/dist/swimlanesDiagram-G3AALYLV-DiOi9bzU.js +0 -16
  135. package/dist/timeline-definition-FHXFAJF6-Bme2FWbh.js +0 -1597
  136. package/dist/vennDiagram-L72KCM5P-BUQgnZDB.js +0 -2516
  137. package/dist/wardleyDiagram-EHGQE667-DHR2Avlu.js +0 -976
  138. package/dist/xychartDiagram-FW5EYKEG-V4K5eBMS.js +0 -2000
@@ -1,976 +0,0 @@
1
- #!/usr/bin/env node
2
- import { p as populateCommonDb } from "./chunk-JWPE2WC7-XiIefccF.js";
3
- import { s as setAccDescription, g as getAccDescription, o as getDiagramTitle, n as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, E as getThemeVariables3, y as getConfig, A as cleanAndMerge, l as log, D as selectSvgElement, e as configureSvgSize, p as clear, c as getConfig2 } from "./mermaid.core-Dy_tFRs7.js";
4
- import { p as parse } from "./cynefin-VYW2F7L2-BwTeE-TI.js";
5
- var toPercent = /* @__PURE__ */ __name((value, context) => {
6
- const normalized = value <= 1 ? value * 100 : value;
7
- if (normalized < 0 || normalized > 100) {
8
- throw new Error(
9
- `${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`
10
- );
11
- }
12
- return normalized;
13
- }, "toPercent");
14
- var toCoordinates = /* @__PURE__ */ __name((visibility, evolution, context) => {
15
- return {
16
- x: toPercent(evolution, `${context} evolution`),
17
- y: toPercent(visibility, `${context} visibility`)
18
- };
19
- }, "toCoordinates");
20
- var getFlowFromPort = /* @__PURE__ */ __name((port) => {
21
- if (!port) {
22
- return void 0;
23
- }
24
- if (port === "+<>") {
25
- return "bidirectional";
26
- }
27
- if (port === "+<") {
28
- return "backward";
29
- }
30
- if (port === "+>") {
31
- return "forward";
32
- }
33
- return void 0;
34
- }, "getFlowFromPort");
35
- var extractFlowFromArrow = /* @__PURE__ */ __name((arrow) => {
36
- if (!arrow?.startsWith("+")) {
37
- return {};
38
- }
39
- const labelMatch = /^\+'([^']*)'/.exec(arrow);
40
- const flowLabel = labelMatch?.[1];
41
- if (arrow.includes("<>")) {
42
- return { flow: "bidirectional", label: flowLabel };
43
- }
44
- if (arrow.includes("<")) {
45
- return { flow: "backward", label: flowLabel };
46
- }
47
- if (arrow.includes(">")) {
48
- return { flow: "forward", label: flowLabel };
49
- }
50
- return { label: flowLabel };
51
- }, "extractFlowFromArrow");
52
- var populateDb = /* @__PURE__ */ __name((ast, db) => {
53
- populateCommonDb(ast, db);
54
- if (ast.size) {
55
- db.setSize(ast.size.width, ast.size.height);
56
- }
57
- if (ast.evolution) {
58
- const stages = ast.evolution.stages.map((stage) => {
59
- if (stage.secondName) {
60
- return `${stage.name.trim()} / ${stage.secondName.trim()}`;
61
- }
62
- return stage.name.trim();
63
- });
64
- const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== void 0).map((stage) => stage.boundary);
65
- db.updateAxes({ stages, stageBoundaries });
66
- }
67
- ast.anchors.forEach((anchor) => {
68
- const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
69
- db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
70
- });
71
- ast.components.forEach((component) => {
72
- const coords = toCoordinates(
73
- component.visibility,
74
- component.evolution,
75
- `Component "${component.name}"`
76
- );
77
- const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
78
- const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
79
- const sourceStrategy = component.decorator?.strategy;
80
- db.addNode(
81
- component.name,
82
- component.name,
83
- coords.x,
84
- coords.y,
85
- "component",
86
- labelOffsetX,
87
- labelOffsetY,
88
- component.inertia,
89
- sourceStrategy
90
- );
91
- });
92
- ast.notes.forEach((note) => {
93
- const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
94
- db.addNote(note.text, coords.x, coords.y);
95
- });
96
- ast.pipelines.forEach((pipeline) => {
97
- const parentNode = db.getNode(pipeline.parent);
98
- if (!parentNode || typeof parentNode.y !== "number") {
99
- throw new Error(
100
- `Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`
101
- );
102
- }
103
- const parentY = parentNode.y;
104
- db.startPipeline(pipeline.parent);
105
- pipeline.components.forEach((component) => {
106
- const componentId = `${pipeline.parent}_${component.name}`;
107
- const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
108
- const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
109
- const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
110
- db.addNode(
111
- componentId,
112
- component.name,
113
- x,
114
- parentY,
115
- "pipeline-component",
116
- labelOffsetX,
117
- labelOffsetY
118
- );
119
- db.addPipelineComponent(pipeline.parent, componentId);
120
- });
121
- });
122
- ast.links.forEach((link) => {
123
- const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
124
- let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
125
- const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
126
- if (!flow && arrowFlow) {
127
- flow = arrowFlow;
128
- }
129
- const annotation = link.linkLabel;
130
- const label = flowLabel ?? annotation;
131
- db.addLink(db.resolveNodeId(link.from), db.resolveNodeId(link.to), isDashed, label, flow);
132
- });
133
- ast.evolves.forEach((evolve) => {
134
- const node = db.getNode(evolve.component);
135
- if (node?.y !== void 0) {
136
- const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
137
- db.addTrend(evolve.component, target, node.y);
138
- }
139
- });
140
- if (ast.annotations.length > 0) {
141
- const annotationsBox = ast.annotations[0];
142
- const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
143
- db.setAnnotationsBox(coords.x, coords.y);
144
- }
145
- ast.annotation.forEach((annotation) => {
146
- const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
147
- db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
148
- });
149
- ast.accelerators.forEach((accelerator) => {
150
- const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
151
- db.addAccelerator(accelerator.name, coords.x, coords.y);
152
- });
153
- ast.deaccelerators.forEach((deaccelerator) => {
154
- const coords = toCoordinates(
155
- deaccelerator.x,
156
- deaccelerator.y,
157
- `Deaccelerator "${deaccelerator.name}"`
158
- );
159
- db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
160
- });
161
- }, "populateDb");
162
- var parser = {
163
- parser: {
164
- // @ts-expect-error - WardleyDB is not assignable to DiagramDB
165
- yy: void 0
166
- },
167
- parse: /* @__PURE__ */ __name(async (input) => {
168
- const ast = await parse("wardley", input);
169
- log.debug(ast);
170
- const db = parser.parser?.yy;
171
- if (!db || typeof db.addNode !== "function") {
172
- throw new Error(
173
- "parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
174
- );
175
- }
176
- populateDb(ast, db);
177
- }, "parse")
178
- };
179
- var WardleyBuilder = class {
180
- constructor() {
181
- this.nodes = /* @__PURE__ */ new Map();
182
- this.links = [];
183
- this.trends = /* @__PURE__ */ new Map();
184
- this.pipelines = /* @__PURE__ */ new Map();
185
- this.annotations = [];
186
- this.notes = [];
187
- this.accelerators = [];
188
- this.deaccelerators = [];
189
- this.axes = {};
190
- }
191
- static {
192
- __name(this, "WardleyBuilder");
193
- }
194
- addNode(node) {
195
- const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
196
- const merged = {
197
- ...existing,
198
- ...node,
199
- className: node.className ?? existing.className,
200
- labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
201
- labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
202
- };
203
- this.nodes.set(node.id, merged);
204
- }
205
- addLink(link) {
206
- this.links.push(link);
207
- }
208
- addTrend(trend) {
209
- this.trends.set(trend.nodeId, trend);
210
- }
211
- startPipeline(nodeId) {
212
- this.pipelines.set(nodeId, { nodeId, componentIds: [] });
213
- const node = this.nodes.get(nodeId);
214
- if (node) {
215
- node.isPipelineParent = true;
216
- }
217
- }
218
- addPipelineComponent(pipelineNodeId, componentId) {
219
- const pipeline = this.pipelines.get(pipelineNodeId);
220
- if (pipeline) {
221
- pipeline.componentIds.push(componentId);
222
- }
223
- const node = this.nodes.get(componentId);
224
- if (node) {
225
- node.inPipeline = true;
226
- }
227
- }
228
- addAnnotation(annotation) {
229
- this.annotations.push(annotation);
230
- }
231
- addNote(note) {
232
- this.notes.push(note);
233
- }
234
- addAccelerator(accelerator) {
235
- this.accelerators.push(accelerator);
236
- }
237
- addDeaccelerator(deaccelerator) {
238
- this.deaccelerators.push(deaccelerator);
239
- }
240
- setAnnotationsBox(x, y) {
241
- this.annotationsBox = { x, y };
242
- }
243
- setAxes(partial) {
244
- this.axes = {
245
- ...this.axes,
246
- ...partial
247
- };
248
- }
249
- setSize(width, height) {
250
- this.size = { width, height };
251
- }
252
- getNode(id) {
253
- return this.nodes.get(id);
254
- }
255
- /**
256
- * Resolve a name to a node ID. Tries exact ID match first,
257
- * then falls back to finding a node whose label matches the name
258
- * (handles pipeline components which have synthetic IDs like "Parent_Child").
259
- */
260
- resolveNodeId(name) {
261
- if (this.nodes.has(name)) {
262
- return name;
263
- }
264
- for (const [id, node] of this.nodes) {
265
- if (node.label === name) {
266
- return id;
267
- }
268
- }
269
- return name;
270
- }
271
- build() {
272
- const nodes = [];
273
- for (const node of this.nodes.values()) {
274
- if (typeof node.x !== "number" || typeof node.y !== "number") {
275
- throw new Error(`Node "${node.label}" is missing coordinates`);
276
- }
277
- nodes.push(node);
278
- }
279
- return {
280
- nodes,
281
- links: [...this.links],
282
- trends: [...this.trends.values()],
283
- pipelines: [...this.pipelines.values()],
284
- annotations: [...this.annotations],
285
- notes: [...this.notes],
286
- accelerators: [...this.accelerators],
287
- deaccelerators: [...this.deaccelerators],
288
- annotationsBox: this.annotationsBox,
289
- axes: { ...this.axes },
290
- size: this.size
291
- };
292
- }
293
- clear() {
294
- this.nodes.clear();
295
- this.links = [];
296
- this.trends.clear();
297
- this.pipelines.clear();
298
- this.annotations = [];
299
- this.notes = [];
300
- this.accelerators = [];
301
- this.deaccelerators = [];
302
- this.annotationsBox = void 0;
303
- this.axes = {};
304
- this.size = void 0;
305
- }
306
- };
307
- var builder = new WardleyBuilder();
308
- function getConfig3() {
309
- return getConfig2()["wardley-beta"];
310
- }
311
- __name(getConfig3, "getConfig");
312
- function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
313
- builder.addNode({
314
- id,
315
- label,
316
- x,
317
- y,
318
- className,
319
- labelOffsetX,
320
- labelOffsetY,
321
- inertia,
322
- sourceStrategy
323
- });
324
- }
325
- __name(addNode, "addNode");
326
- function addLink(sourceId, targetId, dashed = false, label, flow) {
327
- builder.addLink({
328
- source: sourceId,
329
- target: targetId,
330
- dashed,
331
- label,
332
- flow
333
- });
334
- }
335
- __name(addLink, "addLink");
336
- function addTrend(nodeId, targetX, targetY) {
337
- builder.addTrend({ nodeId, targetX, targetY });
338
- }
339
- __name(addTrend, "addTrend");
340
- function addAnnotation(number, coordinates, text) {
341
- builder.addAnnotation({
342
- number,
343
- coordinates,
344
- text
345
- });
346
- }
347
- __name(addAnnotation, "addAnnotation");
348
- function addNote(text, x, y) {
349
- builder.addNote({
350
- text,
351
- x,
352
- y
353
- });
354
- }
355
- __name(addNote, "addNote");
356
- function addAccelerator(name, x, y) {
357
- builder.addAccelerator({
358
- name,
359
- x,
360
- y
361
- });
362
- }
363
- __name(addAccelerator, "addAccelerator");
364
- function addDeaccelerator(name, x, y) {
365
- builder.addDeaccelerator({
366
- name,
367
- x,
368
- y
369
- });
370
- }
371
- __name(addDeaccelerator, "addDeaccelerator");
372
- function setAnnotationsBox(x, y) {
373
- builder.setAnnotationsBox(x, y);
374
- }
375
- __name(setAnnotationsBox, "setAnnotationsBox");
376
- function setSize(width, height) {
377
- builder.setSize(width, height);
378
- }
379
- __name(setSize, "setSize");
380
- function startPipeline(nodeId) {
381
- builder.startPipeline(nodeId);
382
- }
383
- __name(startPipeline, "startPipeline");
384
- function addPipelineComponent(pipelineNodeId, componentId) {
385
- builder.addPipelineComponent(pipelineNodeId, componentId);
386
- }
387
- __name(addPipelineComponent, "addPipelineComponent");
388
- function updateAxes(partial) {
389
- builder.setAxes(partial);
390
- }
391
- __name(updateAxes, "updateAxes");
392
- function getNode(id) {
393
- return builder.getNode(id);
394
- }
395
- __name(getNode, "getNode");
396
- function resolveNodeId(name) {
397
- return builder.resolveNodeId(name);
398
- }
399
- __name(resolveNodeId, "resolveNodeId");
400
- function getWardleyData() {
401
- return builder.build();
402
- }
403
- __name(getWardleyData, "getWardleyData");
404
- function clear2() {
405
- builder.clear();
406
- clear();
407
- }
408
- __name(clear2, "clear");
409
- var wardleyDb_default = {
410
- getConfig: getConfig3,
411
- addNode,
412
- addLink,
413
- addTrend,
414
- addAnnotation,
415
- addNote,
416
- addAccelerator,
417
- addDeaccelerator,
418
- setAnnotationsBox,
419
- setSize,
420
- startPipeline,
421
- addPipelineComponent,
422
- updateAxes,
423
- getNode,
424
- resolveNodeId,
425
- getWardleyData,
426
- clear: clear2,
427
- setAccTitle,
428
- getAccTitle,
429
- setDiagramTitle,
430
- getDiagramTitle,
431
- getAccDescription,
432
- setAccDescription
433
- };
434
- var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
435
- var getTheme = /* @__PURE__ */ __name(() => {
436
- const { themeVariables } = getConfig2();
437
- return {
438
- backgroundColor: themeVariables.wardley?.backgroundColor ?? themeVariables.background ?? "#fff",
439
- axisColor: themeVariables.wardley?.axisColor ?? "#000",
440
- axisTextColor: themeVariables.wardley?.axisTextColor ?? themeVariables.primaryTextColor ?? "#222",
441
- gridColor: themeVariables.wardley?.gridColor ?? "rgba(100, 100, 100, 0.2)",
442
- componentFill: themeVariables.wardley?.componentFill ?? "#fff",
443
- componentStroke: themeVariables.wardley?.componentStroke ?? "#000",
444
- componentLabelColor: themeVariables.wardley?.componentLabelColor ?? themeVariables.primaryTextColor ?? "#222",
445
- linkStroke: themeVariables.wardley?.linkStroke ?? "#000",
446
- evolutionStroke: themeVariables.wardley?.evolutionStroke ?? "#dc3545",
447
- annotationStroke: themeVariables.wardley?.annotationStroke ?? "#000",
448
- annotationTextColor: themeVariables.wardley?.annotationTextColor ?? themeVariables.primaryTextColor ?? "#222",
449
- annotationFill: themeVariables.wardley?.annotationFill ?? themeVariables.background ?? "#fff"
450
- };
451
- }, "getTheme");
452
- var getConfigValues = /* @__PURE__ */ __name(() => {
453
- const wardleyConfig = getConfig2()["wardley-beta"];
454
- return {
455
- width: wardleyConfig?.width ?? 900,
456
- height: wardleyConfig?.height ?? 600,
457
- padding: wardleyConfig?.padding ?? 48,
458
- nodeRadius: wardleyConfig?.nodeRadius ?? 6,
459
- nodeLabelOffset: wardleyConfig?.nodeLabelOffset ?? 8,
460
- axisFontSize: wardleyConfig?.axisFontSize ?? 12,
461
- labelFontSize: wardleyConfig?.labelFontSize ?? 10,
462
- showGrid: wardleyConfig?.showGrid ?? false,
463
- useMaxWidth: wardleyConfig?.useMaxWidth ?? true
464
- };
465
- }, "getConfigValues");
466
- var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
467
- log.debug("Rendering Wardley map\n" + text);
468
- const configValues = getConfigValues();
469
- const theme = getTheme();
470
- const squareSize = configValues.nodeRadius * 1.6;
471
- const db = diagObj.db;
472
- const data = db.getWardleyData();
473
- const title = db.getDiagramTitle();
474
- const width = data.size?.width ?? configValues.width;
475
- const height = data.size?.height ?? configValues.height;
476
- const svg = selectSvgElement(id);
477
- svg.selectAll("*").remove();
478
- configureSvgSize(svg, height, width, configValues.useMaxWidth);
479
- svg.attr("viewBox", `0 0 ${width} ${height}`);
480
- const root = svg.append("g").attr("class", "wardley-map");
481
- const defs = svg.append("defs");
482
- defs.append("marker").attr("id", `arrow-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.evolutionStroke).attr("stroke", "none");
483
- defs.append("marker").attr("id", `link-arrow-end-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
484
- defs.append("marker").attr("id", `link-arrow-start-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
485
- root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
486
- const chartWidth = width - configValues.padding * 2;
487
- const chartHeight = height - configValues.padding * 2;
488
- if (title) {
489
- root.append("text").attr("class", "wardley-title").attr("x", width / 2).attr("y", configValues.padding / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
490
- }
491
- const projectX = /* @__PURE__ */ __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
492
- const projectY = /* @__PURE__ */ __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
493
- const axisGroup = root.append("g").attr("class", "wardley-axes");
494
- axisGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
495
- axisGroup.append("line").attr("x1", configValues.padding).attr("x2", configValues.padding).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
496
- const xLabel = data.axes.xLabel ?? "Evolution";
497
- const yLabel = data.axes.yLabel ?? "Visibility";
498
- axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", configValues.padding + chartWidth / 2).attr("y", height - configValues.padding / 4).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(xLabel);
499
- axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", configValues.padding / 3).attr("y", configValues.padding + chartHeight / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr(
500
- "transform",
501
- `rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`
502
- ).text(yLabel);
503
- const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
504
- if (stages.length > 0) {
505
- const stageGroup = root.append("g").attr("class", "wardley-stages");
506
- const boundaries = data.axes.stageBoundaries;
507
- const stagePositions = [];
508
- if (boundaries && boundaries.length === stages.length) {
509
- let prevBoundary = 0;
510
- boundaries.forEach((boundary) => {
511
- stagePositions.push({ start: prevBoundary, end: boundary });
512
- prevBoundary = boundary;
513
- });
514
- } else {
515
- const stageWidth = 1 / stages.length;
516
- stages.forEach((_, index) => {
517
- stagePositions.push({
518
- start: index * stageWidth,
519
- end: (index + 1) * stageWidth
520
- });
521
- });
522
- }
523
- stages.forEach((stage, index) => {
524
- const pos = stagePositions[index];
525
- const startX = configValues.padding + pos.start * chartWidth;
526
- const endX = configValues.padding + pos.end * chartWidth;
527
- const centerX = (startX + endX) / 2;
528
- if (index > 0) {
529
- stageGroup.append("line").attr("x1", startX).attr("x2", startX).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8);
530
- }
531
- stageGroup.append("text").attr("class", "wardley-stage-label").attr("x", centerX).attr("y", height - configValues.padding / 1.5).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize - 2).attr("text-anchor", "middle").text(stage);
532
- });
533
- }
534
- if (configValues.showGrid) {
535
- const gridGroup = root.append("g").attr("class", "wardley-grid");
536
- for (let i = 1; i < 4; i++) {
537
- const ratio = i / 4;
538
- const x = configValues.padding + chartWidth * ratio;
539
- gridGroup.append("line").attr("x1", x).attr("x2", x).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
540
- gridGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding - chartHeight * ratio).attr("y2", height - configValues.padding - chartHeight * ratio).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
541
- }
542
- }
543
- const positions = /* @__PURE__ */ new Map();
544
- data.nodes.forEach((node) => {
545
- positions.set(node.id, {
546
- x: projectX(node.x),
547
- y: projectY(node.y),
548
- node
549
- });
550
- });
551
- if (data.pipelines.length > 0) {
552
- const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
553
- const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
554
- data.pipelines.forEach((pipeline) => {
555
- if (pipeline.componentIds.length === 0) {
556
- return;
557
- }
558
- const sortedComponents = pipeline.componentIds.map((id2) => ({ id: id2, pos: positions.get(id2), node: data.nodes.find((n) => n.id === id2) })).filter((c) => c.pos && c.node).sort((a, b) => a.node.x - b.node.x);
559
- for (let i = 0; i < sortedComponents.length - 1; i++) {
560
- const current = sortedComponents[i];
561
- const next = sortedComponents[i + 1];
562
- pipelineLinksGroup.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", current.pos.x).attr("y1", current.pos.y).attr("x2", next.pos.x).attr("y2", next.pos.y).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
563
- }
564
- let minX = Infinity;
565
- let maxX = -Infinity;
566
- let y = 0;
567
- pipeline.componentIds.forEach((componentId) => {
568
- const pos = positions.get(componentId);
569
- if (pos) {
570
- minX = Math.min(minX, pos.x);
571
- maxX = Math.max(maxX, pos.x);
572
- y = pos.y;
573
- }
574
- });
575
- if (minX !== Infinity && maxX !== -Infinity) {
576
- const padding = 15;
577
- const height2 = configValues.nodeRadius * 4;
578
- const boxTop = y - height2 / 2;
579
- const parentPos = positions.get(pipeline.nodeId);
580
- if (parentPos) {
581
- const centerX = (minX + maxX) / 2;
582
- parentPos.x = centerX;
583
- parentPos.y = boxTop - squareSize / 6;
584
- }
585
- pipelineGroup.append("rect").attr("class", "wardley-pipeline-box").attr("x", minX - padding).attr("y", boxTop).attr("width", maxX - minX + padding * 2).attr("height", height2).attr("fill", "none").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
586
- }
587
- });
588
- }
589
- const linksGroup = root.append("g").attr("class", "wardley-links");
590
- const pipelineMap = /* @__PURE__ */ new Map();
591
- data.pipelines.forEach((pipeline) => {
592
- pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
593
- });
594
- const validLinks = data.links.filter((link) => {
595
- if (!positions.has(link.source) || !positions.has(link.target)) {
596
- return false;
597
- }
598
- const pipelineComponents = pipelineMap.get(link.target);
599
- if (pipelineComponents?.has(link.source)) {
600
- return false;
601
- }
602
- return true;
603
- });
604
- linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
605
- const sourcePos = positions.get(link.source);
606
- const targetPos = positions.get(link.target);
607
- const sourceNode = data.nodes.find((n) => n.id === link.source);
608
- const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
609
- const dx = targetPos.x - sourcePos.x;
610
- const dy = targetPos.y - sourcePos.y;
611
- const distance = Math.sqrt(dx * dx + dy * dy);
612
- return sourcePos.x + dx / distance * radius;
613
- }).attr("y1", (link) => {
614
- const sourcePos = positions.get(link.source);
615
- const targetPos = positions.get(link.target);
616
- const sourceNode = data.nodes.find((n) => n.id === link.source);
617
- const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
618
- const dx = targetPos.x - sourcePos.x;
619
- const dy = targetPos.y - sourcePos.y;
620
- const distance = Math.sqrt(dx * dx + dy * dy);
621
- return sourcePos.y + dy / distance * radius;
622
- }).attr("x2", (link) => {
623
- const sourcePos = positions.get(link.source);
624
- const targetPos = positions.get(link.target);
625
- const targetNode = data.nodes.find((n) => n.id === link.target);
626
- const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
627
- const dx = sourcePos.x - targetPos.x;
628
- const dy = sourcePos.y - targetPos.y;
629
- const distance = Math.sqrt(dx * dx + dy * dy);
630
- return targetPos.x + dx / distance * radius;
631
- }).attr("y2", (link) => {
632
- const sourcePos = positions.get(link.source);
633
- const targetPos = positions.get(link.target);
634
- const targetNode = data.nodes.find((n) => n.id === link.target);
635
- const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
636
- const dx = sourcePos.x - targetPos.x;
637
- const dy = sourcePos.y - targetPos.y;
638
- const distance = Math.sqrt(dx * dx + dy * dy);
639
- return targetPos.y + dy / distance * radius;
640
- }).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
641
- if (link.flow === "forward" || link.flow === "bidirectional") {
642
- return `url(#link-arrow-end-${id})`;
643
- }
644
- return null;
645
- }).attr("marker-start", (link) => {
646
- if (link.flow === "backward" || link.flow === "bidirectional") {
647
- return `url(#link-arrow-start-${id})`;
648
- }
649
- return null;
650
- });
651
- linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
652
- const sourcePos = positions.get(link.source);
653
- const targetPos = positions.get(link.target);
654
- const midX = (sourcePos.x + targetPos.x) / 2;
655
- const dy = targetPos.y - sourcePos.y;
656
- const dx = targetPos.x - sourcePos.x;
657
- const distance = Math.sqrt(dx * dx + dy * dy);
658
- const offset = 8;
659
- const perpX = dy / distance;
660
- return midX + perpX * offset;
661
- }).attr("y", (link) => {
662
- const sourcePos = positions.get(link.source);
663
- const targetPos = positions.get(link.target);
664
- const midY = (sourcePos.y + targetPos.y) / 2;
665
- const dx = targetPos.x - sourcePos.x;
666
- const dy = targetPos.y - sourcePos.y;
667
- const distance = Math.sqrt(dx * dx + dy * dy);
668
- const offset = 8;
669
- const perpY = -dx / distance;
670
- return midY + perpY * offset;
671
- }).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
672
- const sourcePos = positions.get(link.source);
673
- const targetPos = positions.get(link.target);
674
- const midX = (sourcePos.x + targetPos.x) / 2;
675
- const midY = (sourcePos.y + targetPos.y) / 2;
676
- const dx = targetPos.x - sourcePos.x;
677
- const dy = targetPos.y - sourcePos.y;
678
- const distance = Math.sqrt(dx * dx + dy * dy);
679
- const offset = 8;
680
- const perpX = dy / distance;
681
- const perpY = -dx / distance;
682
- const labelX = midX + perpX * offset;
683
- const labelY = midY + perpY * offset;
684
- let angle = Math.atan2(dy, dx) * 180 / Math.PI;
685
- if (angle > 90 || angle < -90) {
686
- angle += 180;
687
- }
688
- return `rotate(${angle} ${labelX} ${labelY})`;
689
- }).text((link) => link.label);
690
- const trendGroup = root.append("g").attr("class", "wardley-trends");
691
- const trendsWithPositions = data.trends.map((trend) => {
692
- const origin = positions.get(trend.nodeId);
693
- if (!origin) {
694
- return null;
695
- }
696
- const targetX = projectX(trend.targetX);
697
- const targetY = projectY(trend.targetY);
698
- const dx = targetX - origin.x;
699
- const dy = targetY - origin.y;
700
- const distance = Math.sqrt(dx * dx + dy * dy);
701
- const shortenBy = configValues.nodeRadius + 2;
702
- const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
703
- const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
704
- return {
705
- origin,
706
- targetX,
707
- targetY,
708
- adjustedX2,
709
- adjustedY2
710
- };
711
- }).filter((trend) => trend !== null);
712
- trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class", "wardley-trend").attr("x1", (trend) => trend.origin.x).attr("y1", (trend) => trend.origin.y).attr("x2", (trend) => trend.adjustedX2).attr("y2", (trend) => trend.adjustedY2).attr("stroke", theme.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${id})`);
713
- const nodesGroup = root.append("g").attr("class", "wardley-nodes");
714
- const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr(
715
- "class",
716
- (node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" ")
717
- );
718
- nodeEnter.filter((node) => node.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#666").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
719
- nodeEnter.filter((node) => node.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
720
- nodeEnter.filter((node) => node.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
721
- const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
722
- marketNodes.append("circle").attr("class", "wardley-market-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
723
- nodeEnter.filter(
724
- (node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor"
725
- ).append("circle").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
726
- const smallCircleRadius = configValues.nodeRadius * 0.7;
727
- const triangleRadius = configValues.nodeRadius * 1.2;
728
- marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x).attr("y1", (node) => positions.get(node.id).y - triangleRadius).attr("x2", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
729
- marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
730
- marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x).attr("y2", (node) => positions.get(node.id).y - triangleRadius).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
731
- marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y - triangleRadius).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
732
- marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
733
- marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
734
- nodeEnter.filter((node) => node.isPipelineParent === true).append("rect").attr("x", (node) => positions.get(node.id).x - squareSize / 2).attr("y", (node) => positions.get(node.id).y - squareSize / 2).attr("width", squareSize).attr("height", squareSize).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
735
- nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
736
- const pos = positions.get(node.id);
737
- let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
738
- if (node.sourceStrategy) {
739
- offset += configValues.nodeRadius + 10;
740
- }
741
- return pos.x + offset;
742
- }).attr("y1", (node) => {
743
- const pos = positions.get(node.id);
744
- const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
745
- return pos.y - lineHeight / 2;
746
- }).attr("x2", (node) => {
747
- const pos = positions.get(node.id);
748
- let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
749
- if (node.sourceStrategy) {
750
- offset += configValues.nodeRadius + 10;
751
- }
752
- return pos.x + offset;
753
- }).attr("y2", (node) => {
754
- const pos = positions.get(node.id);
755
- const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
756
- return pos.y + lineHeight / 2;
757
- }).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
758
- nodeEnter.append("text").attr("x", (node) => {
759
- const pos = positions.get(node.id);
760
- if (node.className === "anchor") {
761
- return node.labelOffsetX !== void 0 ? pos.x + node.labelOffsetX : pos.x;
762
- }
763
- let defaultOffset = configValues.nodeLabelOffset;
764
- if (node.sourceStrategy && node.labelOffsetX === void 0) {
765
- defaultOffset += 10;
766
- }
767
- const customOffset = node.labelOffsetX ?? defaultOffset;
768
- return pos.x + customOffset;
769
- }).attr("y", (node) => {
770
- const pos = positions.get(node.id);
771
- if (node.className === "anchor") {
772
- return node.labelOffsetY !== void 0 ? pos.y + node.labelOffsetY : pos.y - 3;
773
- }
774
- let defaultOffset = -configValues.nodeLabelOffset;
775
- if (node.sourceStrategy && node.labelOffsetY === void 0) {
776
- defaultOffset -= 10;
777
- }
778
- const customOffset = node.labelOffsetY ?? defaultOffset;
779
- return pos.y + customOffset;
780
- }).attr("class", "wardley-node-label").attr("fill", (node) => {
781
- if (node.className === "evolved") {
782
- return theme.evolutionStroke;
783
- }
784
- if (node.className === "anchor") {
785
- return "#000";
786
- }
787
- return theme.componentLabelColor;
788
- }).attr("font-size", configValues.labelFontSize).attr("font-weight", (node) => node.className === "anchor" ? "bold" : "normal").attr("text-anchor", (node) => node.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (node) => node.className === "anchor" ? "middle" : "auto").text((node) => node.label);
789
- if (data.annotations.length > 0) {
790
- const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
791
- data.annotations.forEach((annotation) => {
792
- const projectedCoords = annotation.coordinates.map((coord) => ({
793
- x: projectX(coord.x),
794
- y: projectY(coord.y)
795
- }));
796
- if (projectedCoords.length > 1) {
797
- for (let i = 0; i < projectedCoords.length - 1; i++) {
798
- annotationsGroup.append("line").attr("class", "wardley-annotation-line").attr("x1", projectedCoords[i].x).attr("y1", projectedCoords[i].y).attr("x2", projectedCoords[i + 1].x).attr("y2", projectedCoords[i + 1].y).attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
799
- }
800
- }
801
- projectedCoords.forEach((coord) => {
802
- const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
803
- annotationNode.append("circle").attr("cx", coord.x).attr("cy", coord.y).attr("r", 10).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5);
804
- annotationNode.append("text").attr("x", coord.x).attr("y", coord.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(annotation.number);
805
- });
806
- });
807
- if (data.annotationsBox) {
808
- let boxX = projectX(data.annotationsBox.x);
809
- let boxY = projectY(data.annotationsBox.y);
810
- const padding = 10;
811
- const lineHeight = 16;
812
- const fontSize = 11;
813
- const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
814
- const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
815
- const textElements = [];
816
- sortedAnnotations.forEach((annotation, idx) => {
817
- const text2 = textBoxGroup.append("text").attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight).attr("font-size", fontSize).attr("fill", theme.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${annotation.number}. ${annotation.text}`);
818
- textElements.push(text2);
819
- });
820
- if (textElements.length > 0) {
821
- let maxWidth = 0;
822
- let maxHeight = 0;
823
- textElements.forEach((text2) => {
824
- const textNode = text2.node();
825
- const textWidth = textNode.getComputedTextLength();
826
- maxWidth = Math.max(maxWidth, textWidth);
827
- const bbox = textNode.getBBox();
828
- maxHeight = Math.max(maxHeight, bbox.height);
829
- });
830
- const boxWidth = maxWidth + padding * 2 + 105;
831
- const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
832
- const minX = configValues.padding;
833
- const maxX = width - configValues.padding - boxWidth;
834
- const minY = configValues.padding;
835
- const maxY = height - configValues.padding - boxHeight;
836
- boxX = Math.max(minX, Math.min(boxX, maxX));
837
- boxY = Math.max(minY, Math.min(boxY, maxY));
838
- textElements.forEach((text2, idx) => {
839
- text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
840
- });
841
- textBoxGroup.insert("rect", "text").attr("x", boxX).attr("y", boxY).attr("width", boxWidth).attr("height", boxHeight).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
842
- }
843
- }
844
- }
845
- if (data.notes.length > 0) {
846
- const notesGroup = root.append("g").attr("class", "wardley-notes");
847
- data.notes.forEach((note) => {
848
- const noteX = projectX(note.x);
849
- const noteY = projectY(note.y);
850
- notesGroup.append("text").attr("x", noteX).attr("y", noteY).attr("text-anchor", "start").attr("font-size", 11).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(note.text);
851
- });
852
- }
853
- if (data.accelerators.length > 0) {
854
- const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
855
- data.accelerators.forEach((accelerator) => {
856
- const accX = projectX(accelerator.x);
857
- const accY = projectY(accelerator.y);
858
- const arrowWidth = 60;
859
- const arrowHeight = 30;
860
- const arrowHeadWidth = 20;
861
- const arrowPath = `
862
- M ${accX} ${accY - arrowHeight / 2}
863
- L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
864
- L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
865
- L ${accX + arrowWidth} ${accY}
866
- L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
867
- L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
868
- L ${accX} ${accY + arrowHeight / 2}
869
- Z
870
- `;
871
- acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
872
- acceleratorsGroup.append("text").attr("x", accX + arrowWidth / 2).attr("y", accY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(accelerator.name);
873
- });
874
- }
875
- if (data.deaccelerators.length > 0) {
876
- const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
877
- data.deaccelerators.forEach((deaccelerator) => {
878
- const decX = projectX(deaccelerator.x);
879
- const decY = projectY(deaccelerator.y);
880
- const arrowWidth = 60;
881
- const arrowHeight = 30;
882
- const arrowHeadWidth = 20;
883
- const arrowPath = `
884
- M ${decX + arrowWidth} ${decY - arrowHeight / 2}
885
- L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
886
- L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
887
- L ${decX} ${decY}
888
- L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
889
- L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
890
- L ${decX + arrowWidth} ${decY + arrowHeight / 2}
891
- Z
892
- `;
893
- deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
894
- deacceleratorsGroup.append("text").attr("x", decX + arrowWidth / 2).attr("y", decY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(deaccelerator.name);
895
- });
896
- }
897
- }, "draw");
898
- var wardleyRenderer_default = {
899
- draw
900
- };
901
- var styles = /* @__PURE__ */ __name(({
902
- wardley
903
- } = {}) => {
904
- const defaultThemeVariables = getThemeVariables3();
905
- const currentConfig = getConfig();
906
- const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
907
- const w = cleanAndMerge(themeVariables.wardley, wardley);
908
- return `
909
- .wardley-background {
910
- fill: ${w.backgroundColor};
911
- }
912
- .wardley-axes line, .wardley-axes path {
913
- stroke: ${w.axisColor};
914
- }
915
- .wardley-axis-label {
916
- fill: ${w.axisTextColor};
917
- }
918
- .wardley-stage-label {
919
- fill: ${w.axisTextColor};
920
- }
921
- .wardley-grid line {
922
- stroke: ${w.gridColor};
923
- }
924
- .wardley-node circle {
925
- fill: ${w.componentFill};
926
- stroke: ${w.componentStroke};
927
- }
928
- .wardley-node-label {
929
- fill: ${w.componentLabelColor};
930
- }
931
- .wardley-link {
932
- stroke: ${w.linkStroke};
933
- }
934
- .wardley-link--dashed {
935
- stroke-dasharray: 4 4;
936
- }
937
- .wardley-link-label {
938
- fill: ${w.axisTextColor};
939
- }
940
- .wardley-trend line {
941
- stroke: ${w.evolutionStroke};
942
- }
943
- .wardley-annotation-line {
944
- stroke: ${w.annotationStroke};
945
- }
946
- .wardley-annotation circle {
947
- fill: ${w.annotationFill};
948
- stroke: ${w.annotationStroke};
949
- }
950
- .wardley-annotation text {
951
- fill: ${w.annotationTextColor};
952
- }
953
- .wardley-annotations-box rect {
954
- fill: ${w.annotationFill};
955
- stroke: ${w.annotationStroke};
956
- }
957
- .wardley-annotations-box text {
958
- fill: ${w.annotationTextColor};
959
- }
960
- .wardley-pipeline-box {
961
- stroke: ${w.componentStroke};
962
- }
963
- .wardley-notes text {
964
- fill: ${w.axisTextColor};
965
- }
966
- `;
967
- }, "styles");
968
- var diagram = {
969
- parser,
970
- db: wardleyDb_default,
971
- renderer: wardleyRenderer_default,
972
- styles
973
- };
974
- export {
975
- diagram
976
- };