@transitrix/diagrams 1.8.4 → 1.8.7

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 (254) hide show
  1. package/dist/edge-path.js +10 -1
  2. package/dist/webview/render-activities.d.ts +1 -1
  3. package/dist/webview/render-activities.js +2 -2
  4. package/dist/webview/render-fgca.js +1 -4
  5. package/package.json +7 -2
  6. package/src/edge-path.ts +15 -1
  7. package/src/webview/render-activities.ts +2 -2
  8. package/src/webview/render-fgca.ts +1 -4
  9. package/dist/__tests__/edge-path.test.d.ts +0 -1
  10. package/dist/__tests__/edge-path.test.js +0 -47
  11. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  12. package/dist/__tests__/node-size-presets.test.js +0 -30
  13. package/dist/__tests__/scope.test.d.ts +0 -1
  14. package/dist/__tests__/scope.test.js +0 -23
  15. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  16. package/dist/__tests__/yaml-normalize.test.js +0 -148
  17. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  18. package/dist/activities/__tests__/cpm.test.js +0 -146
  19. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  20. package/dist/activities/__tests__/gantt.test.js +0 -263
  21. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  22. package/dist/activities/__tests__/layout.test.js +0 -98
  23. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  24. package/dist/activities/__tests__/validate.test.js +0 -397
  25. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  26. package/dist/activity-card/__tests__/example.test.js +0 -73
  27. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  28. package/dist/activity-card/__tests__/layout.test.js +0 -141
  29. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  30. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  31. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  32. package/dist/activity-card/__tests__/validate.test.js +0 -149
  33. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  34. package/dist/actor/__tests__/validate.test.js +0 -95
  35. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  36. package/dist/applications/__tests__/validate.test.js +0 -223
  37. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  38. package/dist/assertion/__tests__/example.test.js +0 -32
  39. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  40. package/dist/assertion/__tests__/validate.test.js +0 -130
  41. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  42. package/dist/blocks/__tests__/layout.test.js +0 -153
  43. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  44. package/dist/blocks/__tests__/validate.test.js +0 -235
  45. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  46. package/dist/business-service/__tests__/validate.test.js +0 -135
  47. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  48. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  49. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  50. package/dist/capability-map/__tests__/address.test.js +0 -49
  51. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  52. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  53. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  54. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  55. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  56. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  57. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  58. package/dist/capability-map/__tests__/validate.test.js +0 -212
  59. package/dist/change/__tests__/validate.test.d.ts +0 -1
  60. package/dist/change/__tests__/validate.test.js +0 -79
  61. package/dist/codex/__tests__/example.test.d.ts +0 -1
  62. package/dist/codex/__tests__/example.test.js +0 -33
  63. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  64. package/dist/codex/__tests__/validate.test.js +0 -68
  65. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  66. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  67. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  68. package/dist/compliance/__tests__/classify.test.js +0 -58
  69. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  70. package/dist/compliance/__tests__/confidence.test.js +0 -78
  71. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  72. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  73. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  74. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  75. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  76. package/dist/compliance/__tests__/example.test.js +0 -51
  77. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  78. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  79. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  80. package/dist/compliance/__tests__/html.test.js +0 -122
  81. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  82. package/dist/compliance/__tests__/impact.test.js +0 -913
  83. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  84. package/dist/compliance/__tests__/markdown.test.js +0 -85
  85. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  86. package/dist/compliance/__tests__/trace.test.js +0 -144
  87. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  88. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  89. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  90. package/dist/compliance/__tests__/views.test.js +0 -59
  91. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  92. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  93. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  94. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  95. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  96. package/dist/confidence/__tests__/score.test.js +0 -188
  97. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  98. package/dist/constraint/__tests__/example.test.js +0 -14
  99. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  100. package/dist/constraint/__tests__/validate.test.js +0 -58
  101. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  102. package/dist/factor/__tests__/validate.test.js +0 -112
  103. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  104. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  105. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  106. package/dist/fgca/__tests__/layout.test.js +0 -140
  107. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  108. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  109. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  110. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  111. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  112. package/dist/fgca/__tests__/resolver.test.js +0 -185
  113. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  114. package/dist/fgca/__tests__/validate.test.js +0 -125
  115. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  116. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  117. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  118. package/dist/goals/__tests__/layout.test.js +0 -153
  119. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  120. package/dist/goals/__tests__/mutations.test.js +0 -134
  121. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  122. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  123. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  124. package/dist/goals/__tests__/validate.test.js +0 -183
  125. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  126. package/dist/integration/__tests__/validate.test.js +0 -169
  127. package/dist/location/__tests__/validate.test.d.ts +0 -1
  128. package/dist/location/__tests__/validate.test.js +0 -107
  129. package/dist/node/__tests__/validate.test.d.ts +0 -1
  130. package/dist/node/__tests__/validate.test.js +0 -100
  131. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  132. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  133. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  134. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  135. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  136. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  137. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  138. package/dist/process-map/__tests__/validate.test.js +0 -199
  139. package/dist/products/__tests__/validate.test.d.ts +0 -1
  140. package/dist/products/__tests__/validate.test.js +0 -210
  141. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  142. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  143. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  144. package/dist/requirement/__tests__/example.test.js +0 -21
  145. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  146. package/dist/requirement/__tests__/validate.test.js +0 -80
  147. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  148. package/dist/scenarios/__tests__/validate.test.js +0 -183
  149. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  150. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  151. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  152. package/dist/target-state/__tests__/validate.test.js +0 -78
  153. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  154. package/dist/technology-service/__tests__/validate.test.js +0 -121
  155. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  156. package/dist/theme/__tests__/tokens.test.js +0 -159
  157. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  158. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  159. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  160. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  161. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  162. package/dist/webview/__tests__/entry.test.js +0 -56
  163. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  164. package/dist/webview/__tests__/render-activities.test.js +0 -91
  165. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  166. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  167. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  168. package/dist/webview/__tests__/render-goals.test.js +0 -120
  169. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  170. package/dist/webview/__tests__/render-process.test.js +0 -463
  171. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  172. package/dist/webview/__tests__/render-util.test.js +0 -54
  173. package/src/__tests__/edge-path.test.ts +0 -58
  174. package/src/__tests__/node-size-presets.test.ts +0 -50
  175. package/src/__tests__/scope.test.ts +0 -27
  176. package/src/__tests__/yaml-normalize.test.ts +0 -158
  177. package/src/activities/__tests__/cpm.test.ts +0 -164
  178. package/src/activities/__tests__/gantt.test.ts +0 -290
  179. package/src/activities/__tests__/layout.test.ts +0 -112
  180. package/src/activities/__tests__/validate.test.ts +0 -446
  181. package/src/activity-card/__tests__/example.test.ts +0 -83
  182. package/src/activity-card/__tests__/layout.test.ts +0 -162
  183. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  184. package/src/activity-card/__tests__/validate.test.ts +0 -167
  185. package/src/actor/__tests__/validate.test.ts +0 -114
  186. package/src/applications/__tests__/validate.test.ts +0 -256
  187. package/src/assertion/__tests__/example.test.ts +0 -37
  188. package/src/assertion/__tests__/validate.test.ts +0 -142
  189. package/src/blocks/__tests__/layout.test.ts +0 -169
  190. package/src/blocks/__tests__/validate.test.ts +0 -260
  191. package/src/business-service/__tests__/validate.test.ts +0 -160
  192. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  193. package/src/capability-map/__tests__/address.test.ts +0 -59
  194. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  195. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  196. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  197. package/src/capability-map/__tests__/validate.test.ts +0 -238
  198. package/src/change/__tests__/validate.test.ts +0 -97
  199. package/src/codex/__tests__/example.test.ts +0 -40
  200. package/src/codex/__tests__/validate.test.ts +0 -84
  201. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  202. package/src/compliance/__tests__/classify.test.ts +0 -64
  203. package/src/compliance/__tests__/confidence.test.ts +0 -98
  204. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  205. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  206. package/src/compliance/__tests__/example.test.ts +0 -57
  207. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  208. package/src/compliance/__tests__/html.test.ts +0 -142
  209. package/src/compliance/__tests__/impact.test.ts +0 -1060
  210. package/src/compliance/__tests__/markdown.test.ts +0 -95
  211. package/src/compliance/__tests__/trace.test.ts +0 -157
  212. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  213. package/src/compliance/__tests__/views.test.ts +0 -64
  214. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  215. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  216. package/src/confidence/__tests__/score.test.ts +0 -254
  217. package/src/constraint/__tests__/example.test.ts +0 -19
  218. package/src/constraint/__tests__/validate.test.ts +0 -68
  219. package/src/factor/__tests__/validate.test.ts +0 -133
  220. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  221. package/src/fgca/__tests__/layout.test.ts +0 -179
  222. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  223. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  224. package/src/fgca/__tests__/resolver.test.ts +0 -209
  225. package/src/fgca/__tests__/validate.test.ts +0 -142
  226. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  227. package/src/goals/__tests__/layout.test.ts +0 -175
  228. package/src/goals/__tests__/mutations.test.ts +0 -153
  229. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  230. package/src/goals/__tests__/validate.test.ts +0 -202
  231. package/src/integration/__tests__/validate.test.ts +0 -203
  232. package/src/location/__tests__/validate.test.ts +0 -127
  233. package/src/node/__tests__/validate.test.ts +0 -118
  234. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  235. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  236. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  237. package/src/process-map/__tests__/validate.test.ts +0 -223
  238. package/src/products/__tests__/validate.test.ts +0 -239
  239. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  240. package/src/requirement/__tests__/example.test.ts +0 -24
  241. package/src/requirement/__tests__/validate.test.ts +0 -96
  242. package/src/scenarios/__tests__/validate.test.ts +0 -209
  243. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  244. package/src/target-state/__tests__/validate.test.ts +0 -95
  245. package/src/technology-service/__tests__/validate.test.ts +0 -143
  246. package/src/theme/__tests__/tokens.test.ts +0 -185
  247. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  248. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  249. package/src/webview/__tests__/entry.test.ts +0 -64
  250. package/src/webview/__tests__/render-activities.test.ts +0 -100
  251. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  252. package/src/webview/__tests__/render-goals.test.ts +0 -128
  253. package/src/webview/__tests__/render-process.test.ts +0 -538
  254. package/src/webview/__tests__/render-util.test.ts +0 -66
package/dist/edge-path.js CHANGED
@@ -15,6 +15,15 @@
15
15
  export const EDGE_MIN_HANDLE = 64;
16
16
  const DX_FACTOR = 0.5;
17
17
  const DY_FACTOR = 0.8;
18
+ /**
19
+ * Ceiling on each span factor's contribution. Uncapped, a tall edge with a
20
+ * narrow column gap (large dy, small dx — the common case in a many-row
21
+ * network view) grows a handle far past the endpoints' actual x-distance;
22
+ * the two control points then overshoot each other, producing an
23
+ * exaggerated S-bow instead of a gentle curve. Capping keeps typical spans
24
+ * (within the existing historical range) untouched while reining in outliers.
25
+ */
26
+ const MAX_HANDLE = 160;
18
27
  /** Multiplier applied to the base handle length. 1 = historical appearance. */
19
28
  export const DEFAULT_EDGE_CURVATURE = 1;
20
29
  /**
@@ -33,7 +42,7 @@ export const DEFAULT_EDGE_CURVATURE = 1;
33
42
  export function horizontalCubicEdgePath(sx, sy, tx, ty, curvature = DEFAULT_EDGE_CURVATURE, entryCurvature) {
34
43
  const dx = tx - sx;
35
44
  const dy = ty - sy;
36
- const baseHandle = Math.max(EDGE_MIN_HANDLE, Math.abs(dx) * DX_FACTOR, Math.abs(dy) * DY_FACTOR);
45
+ const baseHandle = Math.max(EDGE_MIN_HANDLE, Math.min(Math.abs(dx) * DX_FACTOR, MAX_HANDLE), Math.min(Math.abs(dy) * DY_FACTOR, MAX_HANDLE));
37
46
  const exitHandle = baseHandle * curvature;
38
47
  const entryHandle = baseHandle * (entryCurvature ?? curvature);
39
48
  return `M${sx},${sy} C${sx + exitHandle},${sy} ${tx - entryHandle},${ty} ${tx},${ty}`;
@@ -7,7 +7,7 @@ import { type NodeSizePreset } from '../node-size-presets.js';
7
7
  * network subset. Embedded alongside the shared theme CSS so the SVG is
8
8
  * self-contained for the JCEF host.
9
9
  */
10
- export declare const ACTIVITIES_NETWORK_CSS = "\n .act-node { fill: var(--ts-layer-activity, #d4edda); stroke: var(--ts-node-stroke, #004d67); stroke-width: 1; }\n .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2.5; }\n .milestone-node { fill: #ecfeff; stroke: var(--ts-text-muted, #64748b); stroke-dasharray: 4 2; }\n .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2; }\n .arrow-fill-critical { fill: var(--ts-brand-orange, #ff4d00); }\n";
10
+ export declare const ACTIVITIES_NETWORK_CSS = "\n .act-node { fill: var(--ts-layer-activity, #d4edda); stroke: var(--ts-node-stroke, #004d67); stroke-width: 1; }\n .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1; }\n .milestone-node { fill: #ecfeff; stroke: var(--ts-text-muted, #64748b); stroke-dasharray: 4 2; }\n .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1.5; }\n .arrow-fill-critical { fill: var(--ts-brand-orange, #ff4d00); }\n";
11
11
  /** Arrowhead marker defs shared by both hosts for the network view. */
12
12
  export declare const ACTIVITIES_NETWORK_DEFS = "<defs>\n <marker id=\"arrow\" markerWidth=\"8\" markerHeight=\"8\" refX=\"8\" refY=\"3\" orient=\"auto\">\n <path d=\"M0,0 L0,6 L8,3 z\" class=\"arrow-fill\"/>\n </marker>\n <marker id=\"arrow-crit\" markerWidth=\"8\" markerHeight=\"8\" refX=\"8\" refY=\"3\" orient=\"auto\">\n <path d=\"M0,0 L0,6 L8,3 z\" class=\"arrow-fill-critical\"/>\n </marker>\n</defs>";
13
13
  /**
@@ -32,9 +32,9 @@ const N_PAD = 24;
32
32
  */
33
33
  export const ACTIVITIES_NETWORK_CSS = `
34
34
  .act-node { fill: var(--ts-layer-activity, #d4edda); stroke: var(--ts-node-stroke, #004d67); stroke-width: 1; }
35
- .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2.5; }
35
+ .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1; }
36
36
  .milestone-node { fill: #ecfeff; stroke: var(--ts-text-muted, #64748b); stroke-dasharray: 4 2; }
37
- .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2; }
37
+ .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1.5; }
38
38
  .arrow-fill-critical { fill: var(--ts-brand-orange, #ff4d00); }
39
39
  `;
40
40
  /** Arrowhead marker defs shared by both hosts for the network view. */
@@ -38,10 +38,7 @@ export function renderFgcaBody(columns, nodes, edges, curvature, entryCurvature,
38
38
  const nodeHeight = bodyOptions.nodeHeight ?? FGCA_NODE_H;
39
39
  const headerTruncate = Math.max(8, Math.floor((nodeWidth - 16) / 7));
40
40
  const headerSvg = columns
41
- .map(({ col, x }) => [
42
- `<rect class="diagram-node layer-${col}" x="${x}" y="${PAD}" width="${nodeWidth}" height="${HEADER_H}" rx="6"/>`,
43
- `<text class="text-header" x="${x + nodeWidth / 2}" y="${PAD + HEADER_H / 2}" text-anchor="middle" dominant-baseline="central">${escXml(truncateLine(COL_LABELS[col], headerTruncate))}</text>`,
44
- ].join('\n'))
41
+ .map(({ col, x }) => `<text class="text-header" x="${x + nodeWidth / 2}" y="${PAD + HEADER_H / 2}" text-anchor="middle" dominant-baseline="central">${escXml(truncateLine(COL_LABELS[col], headerTruncate))}</text>`)
45
42
  .join('\n');
46
43
  const edgeSvg = edges
47
44
  .map((e) => `<path d="${horizontalCubicEdgePath(e.sx, e.sy, e.tx, e.ty, curvature, entryCurvature)}" class="diagram-edge" marker-end="url(#arrow)"/>`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transitrix/diagrams",
3
- "version": "1.8.4",
3
+ "version": "1.8.7",
4
4
  "type": "module",
5
5
  "description": "Shared rendering, validation, and pure mutations for Transitrix custom diagram formats.",
6
6
  "license": "MIT",
@@ -31,7 +31,12 @@
31
31
  },
32
32
  "files": [
33
33
  "dist",
34
- "src"
34
+ "src",
35
+ "!src/**/__tests__",
36
+ "!src/**/*.test.ts",
37
+ "!src/**/*.test.tsx",
38
+ "!src/**/*.js.map",
39
+ "!src/**/*.d.ts.map"
35
40
  ],
36
41
  "scripts": {
37
42
  "build": "tsc -p .",
package/src/edge-path.ts CHANGED
@@ -17,6 +17,16 @@ export const EDGE_MIN_HANDLE = 64;
17
17
  const DX_FACTOR = 0.5;
18
18
  const DY_FACTOR = 0.8;
19
19
 
20
+ /**
21
+ * Ceiling on each span factor's contribution. Uncapped, a tall edge with a
22
+ * narrow column gap (large dy, small dx — the common case in a many-row
23
+ * network view) grows a handle far past the endpoints' actual x-distance;
24
+ * the two control points then overshoot each other, producing an
25
+ * exaggerated S-bow instead of a gentle curve. Capping keeps typical spans
26
+ * (within the existing historical range) untouched while reining in outliers.
27
+ */
28
+ const MAX_HANDLE = 160;
29
+
20
30
  /** Multiplier applied to the base handle length. 1 = historical appearance. */
21
31
  export const DEFAULT_EDGE_CURVATURE = 1;
22
32
 
@@ -43,7 +53,11 @@ export function horizontalCubicEdgePath(
43
53
  ): string {
44
54
  const dx = tx - sx;
45
55
  const dy = ty - sy;
46
- const baseHandle = Math.max(EDGE_MIN_HANDLE, Math.abs(dx) * DX_FACTOR, Math.abs(dy) * DY_FACTOR);
56
+ const baseHandle = Math.max(
57
+ EDGE_MIN_HANDLE,
58
+ Math.min(Math.abs(dx) * DX_FACTOR, MAX_HANDLE),
59
+ Math.min(Math.abs(dy) * DY_FACTOR, MAX_HANDLE),
60
+ );
47
61
  const exitHandle = baseHandle * curvature;
48
62
  const entryHandle = baseHandle * (entryCurvature ?? curvature);
49
63
  return `M${sx},${sy} C${sx + exitHandle},${sy} ${tx - entryHandle},${ty} ${tx},${ty}`;
@@ -39,9 +39,9 @@ const N_PAD = 24;
39
39
  */
40
40
  export const ACTIVITIES_NETWORK_CSS = `
41
41
  .act-node { fill: var(--ts-layer-activity, #d4edda); stroke: var(--ts-node-stroke, #004d67); stroke-width: 1; }
42
- .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2.5; }
42
+ .critical-node { fill: var(--ts-brand-orange-tint, #ffeee5); stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1; }
43
43
  .milestone-node { fill: #ecfeff; stroke: var(--ts-text-muted, #64748b); stroke-dasharray: 4 2; }
44
- .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 2; }
44
+ .critical-edge { stroke: var(--ts-brand-orange, #ff4d00); stroke-width: 1.5; }
45
45
  .arrow-fill-critical { fill: var(--ts-brand-orange, #ff4d00); }
46
46
  `;
47
47
 
@@ -64,10 +64,7 @@ export function renderFgcaBody(
64
64
 
65
65
  const headerSvg = columns
66
66
  .map(({ col, x }) =>
67
- [
68
- `<rect class="diagram-node layer-${col}" x="${x}" y="${PAD}" width="${nodeWidth}" height="${HEADER_H}" rx="6"/>`,
69
- `<text class="text-header" x="${x + nodeWidth / 2}" y="${PAD + HEADER_H / 2}" text-anchor="middle" dominant-baseline="central">${escXml(truncateLine(COL_LABELS[col], headerTruncate))}</text>`,
70
- ].join('\n'),
67
+ `<text class="text-header" x="${x + nodeWidth / 2}" y="${PAD + HEADER_H / 2}" text-anchor="middle" dominant-baseline="central">${escXml(truncateLine(COL_LABELS[col], headerTruncate))}</text>`,
71
68
  )
72
69
  .join('\n');
73
70
 
@@ -1 +0,0 @@
1
- export {};
@@ -1,47 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { horizontalCubicEdgePath, EDGE_MIN_HANDLE } from '../edge-path.js';
3
- describe('horizontalCubicEdgePath', () => {
4
- // A short horizontal edge: |dx|=40 < EDGE_MIN_HANDLE*2, |dy|=0, so the
5
- // base handle is the floor (64).
6
- const sx = 0, sy = 0, tx = 40, ty = 0;
7
- it('curvature 1 uses the floor handle (historical appearance)', () => {
8
- const d = horizontalCubicEdgePath(sx, sy, tx, ty, 1);
9
- // handle = max(64, 20, 0) = 64
10
- expect(d).toBe(`M0,0 C${EDGE_MIN_HANDLE},0 ${40 - EDGE_MIN_HANDLE},0 40,0`);
11
- });
12
- it('default curvature equals explicit curvature 1', () => {
13
- expect(horizontalCubicEdgePath(sx, sy, tx, ty)).toBe(horizontalCubicEdgePath(sx, sy, tx, ty, 1));
14
- });
15
- it('curvature 0 collapses control points onto the endpoints (straight line)', () => {
16
- const d = horizontalCubicEdgePath(sx, sy, tx, ty, 0);
17
- expect(d).toBe('M0,0 C0,0 40,0 40,0');
18
- });
19
- it('changing curvature changes the path output (AC#6)', () => {
20
- const a = horizontalCubicEdgePath(sx, sy, tx, ty, 1);
21
- const b = horizontalCubicEdgePath(sx, sy, tx, ty, 2);
22
- expect(b).not.toBe(a);
23
- });
24
- it('larger curvature pushes the control handles further out', () => {
25
- const handleOf = (curv) => {
26
- // First control point x is `sx + handle`; parse it back out.
27
- const m = horizontalCubicEdgePath(0, 0, 40, 0, curv).match(/^M0,0 C(-?\d+(?:\.\d+)?),0/);
28
- return Number(m[1]);
29
- };
30
- expect(handleOf(2)).toBeGreaterThan(handleOf(1));
31
- expect(handleOf(0.5)).toBeLessThan(handleOf(1));
32
- expect(handleOf(2)).toBe(2 * EDGE_MIN_HANDLE);
33
- });
34
- it('handle scales with the vertical span for stacked nodes', () => {
35
- // |dy|=200 ⇒ base handle = max(64, 0, 160) = 160; ×1 = 160.
36
- const d = horizontalCubicEdgePath(0, 0, 0, 200, 1);
37
- expect(d).toBe('M0,0 C160,0 -160,200 0,200');
38
- });
39
- it('entryCurvature independently scales the arrival handle', () => {
40
- // exit handle = max(64,20,0)*1 = 64; entry handle = max(64,20,0)*2 = 128.
41
- const d = horizontalCubicEdgePath(0, 0, 40, 0, 1, 2);
42
- expect(d).toBe(`M0,0 C${EDGE_MIN_HANDLE},0 ${40 - EDGE_MIN_HANDLE * 2},0 40,0`);
43
- });
44
- it('omitting entryCurvature gives symmetric handles (historical behaviour)', () => {
45
- expect(horizontalCubicEdgePath(0, 0, 40, 0, 0.5)).toBe(horizontalCubicEdgePath(0, 0, 40, 0, 0.5, 0.5));
46
- });
47
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { ACTION_NODE_SIZE, BLOCKS_LEAF_SIZE, CAPABILITY_MAP_NODE_SIZE, DGCA_NODE_SIZE, ENTITY_NODE_HEIGHT, ENTITY_NODE_SIZE, ENTITY_NODE_WIDTH, GOALS_NODE_SIZE, PROCESS_BLUEPRINT_SIZE, resolveGoalsNodeSize, } from '../node-size-presets.js';
3
- describe('node-size-presets', () => {
4
- it('uses shared width and height tiers for entity nodes', () => {
5
- expect(ENTITY_NODE_WIDTH).toEqual({ compact: 200, normal: 250, wide: 320 });
6
- expect(ENTITY_NODE_HEIGHT).toEqual({ compact: 72, normal: 80, wide: 96 });
7
- expect(ENTITY_NODE_SIZE.normal).toEqual({ width: 250, height: 80 });
8
- expect(ENTITY_NODE_SIZE.compact).toEqual({ width: 200, height: 72 });
9
- expect(ENTITY_NODE_SIZE.wide).toEqual({ width: 320, height: 96 });
10
- });
11
- it('exposes the same entity sizes for every box-based notation', () => {
12
- for (const table of [GOALS_NODE_SIZE, DGCA_NODE_SIZE, BLOCKS_LEAF_SIZE, ACTION_NODE_SIZE]) {
13
- expect(table).toBe(ENTITY_NODE_SIZE);
14
- expect(table.normal).toEqual(ENTITY_NODE_SIZE.normal);
15
- }
16
- expect(CAPABILITY_MAP_NODE_SIZE.normal).toEqual({
17
- nodeWidth: ENTITY_NODE_WIDTH.normal,
18
- nodeHeight: ENTITY_NODE_HEIGHT.normal,
19
- });
20
- });
21
- it('scales wide above normal and compact below', () => {
22
- expect(resolveGoalsNodeSize('wide').height).toBeGreaterThan(resolveGoalsNodeSize('normal').height);
23
- expect(resolveGoalsNodeSize('compact').height).toBeLessThan(resolveGoalsNodeSize('normal').height);
24
- expect(resolveGoalsNodeSize('wide').width).toBeGreaterThan(resolveGoalsNodeSize('normal').width);
25
- });
26
- it('scales process blueprint from the same tier ratios', () => {
27
- expect(PROCESS_BLUEPRINT_SIZE.wide.stageColumnWidth).toBeGreaterThan(PROCESS_BLUEPRINT_SIZE.normal.stageColumnWidth);
28
- expect(PROCESS_BLUEPRINT_SIZE.compact.goalRowHeight).toBeLessThan(PROCESS_BLUEPRINT_SIZE.normal.goalRowHeight);
29
- });
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { checkScopeRoot, SCOPE_MISSING_ROOT_CODE } from '../scope.js';
3
- describe('checkScopeRoot', () => {
4
- it('returns null for non-root scopes', () => {
5
- expect(checkScopeRoot({ mode: 'all' }, [1, 2])).toBeNull();
6
- expect(checkScopeRoot({ mode: 'level', maxLevel: 1 }, [1, 2])).toBeNull();
7
- });
8
- it('returns null when the root id is present (numeric ids compared as strings)', () => {
9
- const scope = { mode: 'root', rootGoalId: '2' };
10
- expect(checkScopeRoot(scope, [1, 2, 3])).toBeNull();
11
- });
12
- it('returns a SCOPE-001 warning when the root id is absent', () => {
13
- const scope = { mode: 'root', rootGoalId: '99' };
14
- const w = checkScopeRoot(scope, [1, 2, 3]);
15
- expect(w).not.toBeNull();
16
- expect(w.code).toBe(SCOPE_MISSING_ROOT_CODE);
17
- expect(w.message).toContain('99');
18
- });
19
- it('handles string goal ids', () => {
20
- expect(checkScopeRoot({ mode: 'root', rootGoalId: 'g1' }, ['g1', 'g2'])).toBeNull();
21
- expect(checkScopeRoot({ mode: 'root', rootGoalId: 'gX' }, ['g1', 'g2'])).not.toBeNull();
22
- });
23
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,148 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
2
- import yaml from 'js-yaml';
3
- import { coerceDatesToIsoStrings } from '../yaml-normalize.js';
4
- import { validateActivities } from '../activities/index.js';
5
- describe('coerceDatesToIsoStrings', () => {
6
- it('replaces top-level Date with ISO YYYY-MM-DD string', () => {
7
- const out = coerceDatesToIsoStrings(new Date(Date.UTC(2026, 5, 1))); // 2026-06-01 UTC
8
- expect(out).toBe('2026-06-01');
9
- });
10
- it('replaces Date values inside nested arrays of objects', () => {
11
- const input = {
12
- activities: [
13
- { id: 'A-001', start_date: new Date(Date.UTC(2026, 5, 1)), end_date: new Date(Date.UTC(2026, 5, 5)) },
14
- { id: 'A-002', start_date: '2026-06-06' },
15
- ],
16
- };
17
- coerceDatesToIsoStrings(input);
18
- expect(input.activities[0].start_date).toBe('2026-06-01');
19
- expect(input.activities[0].end_date).toBe('2026-06-05');
20
- expect(input.activities[1].start_date).toBe('2026-06-06');
21
- });
22
- it('walks objects recursively', () => {
23
- const input = {
24
- project: { start_date: new Date(Date.UTC(2026, 0, 15)) },
25
- };
26
- coerceDatesToIsoStrings(input);
27
- expect(input.project.start_date).toBe('2026-01-15');
28
- });
29
- it('leaves non-Date values untouched', () => {
30
- const input = {
31
- notation: 'activities',
32
- activities: [{ id: 'A-001', duration: 3, start_date: '2026-06-01' }],
33
- };
34
- const out = coerceDatesToIsoStrings(input);
35
- expect(out).toBe(input);
36
- expect(input.activities[0].start_date).toBe('2026-06-01');
37
- expect(input.activities[0].duration).toBe(3);
38
- });
39
- it('handles null, undefined, and primitive scalars', () => {
40
- expect(coerceDatesToIsoStrings(null)).toBe(null);
41
- expect(coerceDatesToIsoStrings(undefined)).toBe(undefined);
42
- expect(coerceDatesToIsoStrings('hello')).toBe('hello');
43
- expect(coerceDatesToIsoStrings(42)).toBe(42);
44
- expect(coerceDatesToIsoStrings(true)).toBe(true);
45
- });
46
- it('handles arrays that contain bare Date elements', () => {
47
- const arr = [new Date(Date.UTC(2026, 5, 1)), 'x', { d: new Date(Date.UTC(2026, 5, 2)) }];
48
- coerceDatesToIsoStrings(arr);
49
- expect(arr[0]).toBe('2026-06-01');
50
- expect(arr[1]).toBe('x');
51
- expect(arr[2].d).toBe('2026-06-02');
52
- });
53
- });
54
- describe('coerceDatesToIsoStrings — js-yaml integration', () => {
55
- it('quoted ISO dates are preserved untouched', () => {
56
- const text = [
57
- 'notation: action',
58
- 'actions:',
59
- ' - id: "A-001"',
60
- ' name: "Quoted dates"',
61
- ' duration: 3',
62
- ' start_date: "2026-06-01"',
63
- ' end_date: "2026-06-03"',
64
- '',
65
- ].join('\n');
66
- const parsed = yaml.load(text);
67
- coerceDatesToIsoStrings(parsed);
68
- expect(parsed.actions[0].start_date).toBe('2026-06-01');
69
- expect(parsed.actions[0].end_date).toBe('2026-06-03');
70
- const v = validateActivities(parsed);
71
- expect(v.valid).toBe(true);
72
- });
73
- it('bare ISO dates are coerced to ISO strings and pass validation', () => {
74
- const text = [
75
- 'notation: action',
76
- 'actions:',
77
- ' - id: "A-001"',
78
- ' name: "Bare dates"',
79
- ' duration: 3',
80
- ' start_date: 2026-06-01',
81
- ' end_date: 2026-06-03',
82
- '',
83
- ].join('\n');
84
- const parsed = yaml.load(text);
85
- // Without coercion, js-yaml returns Date instances and the validator
86
- // would emit ACT-008 because typeof !== 'string'. Sanity-check that
87
- // assumption before normalisation.
88
- expect(parsed.actions[0].start_date).toBeInstanceOf(Date);
89
- coerceDatesToIsoStrings(parsed);
90
- expect(parsed.actions[0].start_date).toBe('2026-06-01');
91
- expect(parsed.actions[0].end_date).toBe('2026-06-03');
92
- const v = validateActivities(parsed);
93
- expect(v.valid).toBe(true);
94
- });
95
- });
96
- // The issue calls out the timezone trap: a Date built from a bare ISO
97
- // date is midnight UTC, but if we used `getFullYear / getMonth / getDate`
98
- // instead of the UTC variants, a non-UTC process timezone would shift the
99
- // day. Pin a non-UTC TZ for this block so the regression bites if anyone
100
- // later swaps to local-time accessors.
101
- describe('coerceDatesToIsoStrings — non-UTC timezone', () => {
102
- const originalTz = process.env.TZ;
103
- beforeAll(() => {
104
- // Pacific/Auckland is UTC+12/+13 — the most aggressive eastward shift
105
- // available without DST gymnastics. If local-time accessors are used,
106
- // `2026-06-01` parsed as midnight UTC reads back as `2026-06-01 12:00
107
- // local`, which is still the right day — so use a westward TZ for the
108
- // real test below. Auckland is here as a sanity case.
109
- process.env.TZ = 'Pacific/Auckland';
110
- });
111
- afterAll(() => {
112
- if (originalTz === undefined) {
113
- delete process.env.TZ;
114
- }
115
- else {
116
- process.env.TZ = originalTz;
117
- }
118
- });
119
- it('does not drift the day forward in an eastward timezone', () => {
120
- const text = 'd: 2026-06-01\n';
121
- const parsed = yaml.load(text);
122
- coerceDatesToIsoStrings(parsed);
123
- expect(parsed.d).toBe('2026-06-01');
124
- });
125
- });
126
- describe('coerceDatesToIsoStrings — westward (negative offset) timezone', () => {
127
- const originalTz = process.env.TZ;
128
- beforeAll(() => {
129
- // Pacific/Honolulu is UTC-10, no DST. Midnight UTC `2026-06-01` reads
130
- // back as `2026-05-31 14:00 local`. Local-time accessors would yield
131
- // `2026-05-31` — wrong by one day. UTC accessors yield `2026-06-01`.
132
- process.env.TZ = 'Pacific/Honolulu';
133
- });
134
- afterAll(() => {
135
- if (originalTz === undefined) {
136
- delete process.env.TZ;
137
- }
138
- else {
139
- process.env.TZ = originalTz;
140
- }
141
- });
142
- it('does not drift the day backward in a westward timezone', () => {
143
- const text = 'd: 2026-06-01\n';
144
- const parsed = yaml.load(text);
145
- coerceDatesToIsoStrings(parsed);
146
- expect(parsed.d).toBe('2026-06-01');
147
- });
148
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,146 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { computeCpm } from '../cpm.js';
3
- // PMBoK textbook example (5-activity network):
4
- // A(5) → B(8) → D(7)
5
- // A(5) → C(3) → D(7)
6
- // D(7) → E(4)
7
- // Critical path: A→B→D→E = 5+8+7+4 = 24
8
- // A: ES=0, EF=5, LS=0, LF=5, slack=0 (critical)
9
- // B: ES=5, EF=13, LS=5, LF=13, slack=0 (critical)
10
- // C: ES=5, EF=8, LS=10, LF=13, slack=5
11
- // D: ES=13, EF=20, LS=13, LF=20, slack=0 (critical)
12
- // E: ES=20, EF=24, LS=20, LF=24, slack=0 (critical)
13
- const pmBokActivities = [
14
- { id: 'A', name: 'A', duration: 5 },
15
- { id: 'B', name: 'B', duration: 8, predecessors: ['A'] },
16
- { id: 'C', name: 'C', duration: 3, predecessors: ['A'] },
17
- { id: 'D', name: 'D', duration: 7, predecessors: ['B', 'C'] },
18
- { id: 'E', name: 'E', duration: 4, predecessors: ['D'] },
19
- ];
20
- describe('computeCpm — PMBoK textbook example', () => {
21
- const result = computeCpm(pmBokActivities);
22
- it('computes ES for each activity', () => {
23
- expect(result.get('A').es).toBe(0);
24
- expect(result.get('B').es).toBe(5);
25
- expect(result.get('C').es).toBe(5);
26
- expect(result.get('D').es).toBe(13);
27
- expect(result.get('E').es).toBe(20);
28
- });
29
- it('computes EF for each activity', () => {
30
- expect(result.get('A').ef).toBe(5);
31
- expect(result.get('B').ef).toBe(13);
32
- expect(result.get('C').ef).toBe(8);
33
- expect(result.get('D').ef).toBe(20);
34
- expect(result.get('E').ef).toBe(24);
35
- });
36
- it('computes LS for each activity', () => {
37
- expect(result.get('A').ls).toBe(0);
38
- expect(result.get('B').ls).toBe(5);
39
- expect(result.get('C').ls).toBe(10);
40
- expect(result.get('D').ls).toBe(13);
41
- expect(result.get('E').ls).toBe(20);
42
- });
43
- it('computes LF for each activity', () => {
44
- expect(result.get('A').lf).toBe(5);
45
- expect(result.get('B').lf).toBe(13);
46
- expect(result.get('C').lf).toBe(13);
47
- expect(result.get('D').lf).toBe(20);
48
- expect(result.get('E').lf).toBe(24);
49
- });
50
- it('computes slack', () => {
51
- expect(result.get('A').slack).toBe(0);
52
- expect(result.get('B').slack).toBe(0);
53
- expect(result.get('C').slack).toBe(5);
54
- expect(result.get('D').slack).toBe(0);
55
- expect(result.get('E').slack).toBe(0);
56
- });
57
- it('marks critical path activities', () => {
58
- expect(result.get('A').isCritical).toBe(true);
59
- expect(result.get('B').isCritical).toBe(true);
60
- expect(result.get('C').isCritical).toBe(false);
61
- expect(result.get('D').isCritical).toBe(true);
62
- expect(result.get('E').isCritical).toBe(true);
63
- });
64
- });
65
- describe('computeCpm — edge cases', () => {
66
- it('returns empty map for empty input', () => {
67
- const result = computeCpm([]);
68
- expect(result.size).toBe(0);
69
- });
70
- it('single node with no predecessors: ES=0, EF=duration, slack=0', () => {
71
- const result = computeCpm([{ id: 'A', name: 'A', duration: 5 }]);
72
- expect(result.get('A').es).toBe(0);
73
- expect(result.get('A').ef).toBe(5);
74
- expect(result.get('A').slack).toBe(0);
75
- expect(result.get('A').isCritical).toBe(true);
76
- });
77
- it('activity with no duration treated as zero-duration', () => {
78
- const result = computeCpm([{ id: 'A', name: 'Milestone' }]);
79
- expect(result.get('A').ef).toBe(0);
80
- });
81
- it('linear chain A(3)→B(5)→C(2): total=10, all critical', () => {
82
- const activities = [
83
- { id: 'A', name: 'A', duration: 3 },
84
- { id: 'B', name: 'B', duration: 5, predecessors: ['A'] },
85
- { id: 'C', name: 'C', duration: 2, predecessors: ['B'] },
86
- ];
87
- const result = computeCpm(activities);
88
- expect(result.get('A').ef).toBe(3);
89
- expect(result.get('B').ef).toBe(8);
90
- expect(result.get('C').ef).toBe(10);
91
- expect(result.get('A').isCritical).toBe(true);
92
- expect(result.get('B').isCritical).toBe(true);
93
- expect(result.get('C').isCritical).toBe(true);
94
- });
95
- it('parallel paths: longer path is critical, shorter has positive slack', () => {
96
- // A(1) → C(10)
97
- // B(5) → C(10)
98
- // merge at D(2): predecessors [C]
99
- // path via A: 1+10+2=13; path via B: 5+10+2=17 → critical
100
- const activities = [
101
- { id: 'A', name: 'A', duration: 1 },
102
- { id: 'B', name: 'B', duration: 5 },
103
- { id: 'C', name: 'C', duration: 10, predecessors: ['A', 'B'] },
104
- { id: 'D', name: 'D', duration: 2, predecessors: ['C'] },
105
- ];
106
- const result = computeCpm(activities);
107
- // C.es = max(EF[A], EF[B]) = max(1,5) = 5
108
- expect(result.get('C').es).toBe(5);
109
- expect(result.get('A').isCritical).toBe(false);
110
- expect(result.get('B').isCritical).toBe(true);
111
- expect(result.get('C').isCritical).toBe(true);
112
- expect(result.get('D').isCritical).toBe(true);
113
- expect(result.get('A').slack).toBe(4);
114
- expect(result.get('B').slack).toBe(0);
115
- });
116
- });
117
- describe('computeCpm — cycle defence', () => {
118
- // Pre-release should-fix: Kahn's topo-order silently omits cyclic nodes.
119
- // The validator's ACT-006 is the authoritative cycle error, but
120
- // layoutActivities is reachable without validation, so computeCpm must
121
- // still produce an entry for every activity (filled with neutral values
122
- // for omitted cyclic ones) — otherwise consumers see `undefined` and
123
- // bars render without CPM data.
124
- it('emits entries for every activity on a 2-node mutual cycle', () => {
125
- const result = computeCpm([
126
- { id: 'A', name: 'A', duration: 3, predecessors: ['B'] },
127
- { id: 'B', name: 'B', duration: 2, predecessors: ['A'] },
128
- ]);
129
- expect(result.size).toBe(2);
130
- expect(result.get('A')).toMatchObject({ es: 0, ef: 0, slack: 0, isCritical: false });
131
- expect(result.get('B')).toMatchObject({ es: 0, ef: 0, slack: 0, isCritical: false });
132
- });
133
- it('keeps real CPM data for the acyclic prefix when a cycle exists downstream', () => {
134
- // A → B is acyclic; C ↔ D is a mutual cycle disconnected from A/B.
135
- const result = computeCpm([
136
- { id: 'A', name: 'A', duration: 5 },
137
- { id: 'B', name: 'B', duration: 3, predecessors: ['A'] },
138
- { id: 'C', name: 'C', duration: 2, predecessors: ['D'] },
139
- { id: 'D', name: 'D', duration: 2, predecessors: ['C'] },
140
- ]);
141
- expect(result.get('A')?.ef).toBe(5);
142
- expect(result.get('B')?.ef).toBe(8);
143
- expect(result.get('C')).toMatchObject({ es: 0, ef: 0, isCritical: false });
144
- expect(result.get('D')).toMatchObject({ es: 0, ef: 0, isCritical: false });
145
- });
146
- });
@@ -1 +0,0 @@
1
- export {};