@cristianormazabal/triton-core 0.1.0

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 (283) hide show
  1. package/dist/contracts/anchors.d.ts +150 -0
  2. package/dist/contracts/anchors.d.ts.map +1 -0
  3. package/dist/contracts/crosslink.d.ts +171 -0
  4. package/dist/contracts/crosslink.d.ts.map +1 -0
  5. package/dist/contracts/diagram.d.ts +107 -0
  6. package/dist/contracts/diagram.d.ts.map +1 -0
  7. package/dist/contracts/index.d.ts +29 -0
  8. package/dist/contracts/index.d.ts.map +1 -0
  9. package/dist/contracts/overlay.d.ts +98 -0
  10. package/dist/contracts/overlay.d.ts.map +1 -0
  11. package/dist/contracts/primitives.d.ts +42 -0
  12. package/dist/contracts/primitives.d.ts.map +1 -0
  13. package/dist/contracts/renderer.d.ts +21 -0
  14. package/dist/contracts/renderer.d.ts.map +1 -0
  15. package/dist/contracts/result.d.ts +32 -0
  16. package/dist/contracts/result.d.ts.map +1 -0
  17. package/dist/contracts/routing.d.ts +60 -0
  18. package/dist/contracts/routing.d.ts.map +1 -0
  19. package/dist/contracts/scene.d.ts +114 -0
  20. package/dist/contracts/scene.d.ts.map +1 -0
  21. package/dist/contracts/theme.d.ts +113 -0
  22. package/dist/contracts/theme.d.ts.map +1 -0
  23. package/dist/crosslink/engine2.d.ts +40 -0
  24. package/dist/crosslink/engine2.d.ts.map +1 -0
  25. package/dist/crosslink/engine3.d.ts +36 -0
  26. package/dist/crosslink/engine3.d.ts.map +1 -0
  27. package/dist/crosslink/index.d.ts +5 -0
  28. package/dist/crosslink/index.d.ts.map +1 -0
  29. package/dist/crosslink/render.d.ts +22 -0
  30. package/dist/crosslink/render.d.ts.map +1 -0
  31. package/dist/crosslink/resolve.d.ts +26 -0
  32. package/dist/crosslink/resolve.d.ts.map +1 -0
  33. package/dist/diagrams/architecture/index.d.ts +5 -0
  34. package/dist/diagrams/architecture/index.d.ts.map +1 -0
  35. package/dist/diagrams/architecture/ir.d.ts +29 -0
  36. package/dist/diagrams/architecture/ir.d.ts.map +1 -0
  37. package/dist/diagrams/architecture/layout.d.ts +11 -0
  38. package/dist/diagrams/architecture/layout.d.ts.map +1 -0
  39. package/dist/diagrams/block/index.d.ts +5 -0
  40. package/dist/diagrams/block/index.d.ts.map +1 -0
  41. package/dist/diagrams/block/ir.d.ts +22 -0
  42. package/dist/diagrams/block/ir.d.ts.map +1 -0
  43. package/dist/diagrams/block/layout.d.ts +12 -0
  44. package/dist/diagrams/block/layout.d.ts.map +1 -0
  45. package/dist/diagrams/c4/index.d.ts +5 -0
  46. package/dist/diagrams/c4/index.d.ts.map +1 -0
  47. package/dist/diagrams/c4/ir.d.ts +33 -0
  48. package/dist/diagrams/c4/ir.d.ts.map +1 -0
  49. package/dist/diagrams/c4/layout.d.ts +12 -0
  50. package/dist/diagrams/c4/layout.d.ts.map +1 -0
  51. package/dist/diagrams/class/index.d.ts +5 -0
  52. package/dist/diagrams/class/index.d.ts.map +1 -0
  53. package/dist/diagrams/class/ir.d.ts +32 -0
  54. package/dist/diagrams/class/ir.d.ts.map +1 -0
  55. package/dist/diagrams/class/layout.d.ts +13 -0
  56. package/dist/diagrams/class/layout.d.ts.map +1 -0
  57. package/dist/diagrams/ds/graph/graph.d.ts +39 -0
  58. package/dist/diagrams/ds/graph/graph.d.ts.map +1 -0
  59. package/dist/diagrams/ds/hashmap/hashmap.d.ts +39 -0
  60. package/dist/diagrams/ds/hashmap/hashmap.d.ts.map +1 -0
  61. package/dist/diagrams/ds/matrix/matrix.d.ts +33 -0
  62. package/dist/diagrams/ds/matrix/matrix.d.ts.map +1 -0
  63. package/dist/diagrams/ds/queue/cqueue.d.ts +31 -0
  64. package/dist/diagrams/ds/queue/cqueue.d.ts.map +1 -0
  65. package/dist/diagrams/ds/queue/deque.d.ts +24 -0
  66. package/dist/diagrams/ds/queue/deque.d.ts.map +1 -0
  67. package/dist/diagrams/ds/queue/pqueue.d.ts +29 -0
  68. package/dist/diagrams/ds/queue/pqueue.d.ts.map +1 -0
  69. package/dist/diagrams/ds/queue/queue.d.ts +27 -0
  70. package/dist/diagrams/ds/queue/queue.d.ts.map +1 -0
  71. package/dist/diagrams/ds/queue/shared.d.ts +35 -0
  72. package/dist/diagrams/ds/queue/shared.d.ts.map +1 -0
  73. package/dist/diagrams/ds/stack/stack.d.ts +28 -0
  74. package/dist/diagrams/ds/stack/stack.d.ts.map +1 -0
  75. package/dist/diagrams/ds/struct/array.d.ts +28 -0
  76. package/dist/diagrams/ds/struct/array.d.ts.map +1 -0
  77. package/dist/diagrams/ds/struct/linkedlist.d.ts +21 -0
  78. package/dist/diagrams/ds/struct/linkedlist.d.ts.map +1 -0
  79. package/dist/diagrams/ds/struct/memory.d.ts +44 -0
  80. package/dist/diagrams/ds/struct/memory.d.ts.map +1 -0
  81. package/dist/diagrams/ds/struct/page.d.ts +25 -0
  82. package/dist/diagrams/ds/struct/page.d.ts.map +1 -0
  83. package/dist/diagrams/ds/struct/shared.d.ts +9 -0
  84. package/dist/diagrams/ds/struct/shared.d.ts.map +1 -0
  85. package/dist/diagrams/ds/tree/avl.d.ts +14 -0
  86. package/dist/diagrams/ds/tree/avl.d.ts.map +1 -0
  87. package/dist/diagrams/ds/tree/btree.d.ts +12 -0
  88. package/dist/diagrams/ds/tree/btree.d.ts.map +1 -0
  89. package/dist/diagrams/ds/tree/build.d.ts +34 -0
  90. package/dist/diagrams/ds/tree/build.d.ts.map +1 -0
  91. package/dist/diagrams/ds/tree/heap.d.ts +12 -0
  92. package/dist/diagrams/ds/tree/heap.d.ts.map +1 -0
  93. package/dist/diagrams/ds/tree/index.d.ts +5 -0
  94. package/dist/diagrams/ds/tree/index.d.ts.map +1 -0
  95. package/dist/diagrams/ds/tree/ir.d.ts +29 -0
  96. package/dist/diagrams/ds/tree/ir.d.ts.map +1 -0
  97. package/dist/diagrams/ds/tree/layout.d.ts +13 -0
  98. package/dist/diagrams/ds/tree/layout.d.ts.map +1 -0
  99. package/dist/diagrams/ds/tree/plan.d.ts +11 -0
  100. package/dist/diagrams/ds/tree/plan.d.ts.map +1 -0
  101. package/dist/diagrams/ds/tree/radix.d.ts +12 -0
  102. package/dist/diagrams/ds/tree/radix.d.ts.map +1 -0
  103. package/dist/diagrams/ds/tree/rbtree.d.ts +12 -0
  104. package/dist/diagrams/ds/tree/rbtree.d.ts.map +1 -0
  105. package/dist/diagrams/ds/tree/segtree.d.ts +12 -0
  106. package/dist/diagrams/ds/tree/segtree.d.ts.map +1 -0
  107. package/dist/diagrams/ds/trie/trie.d.ts +17 -0
  108. package/dist/diagrams/ds/trie/trie.d.ts.map +1 -0
  109. package/dist/diagrams/ds/unionfind/unionfind.d.ts +34 -0
  110. package/dist/diagrams/ds/unionfind/unionfind.d.ts.map +1 -0
  111. package/dist/diagrams/er/index.d.ts +5 -0
  112. package/dist/diagrams/er/index.d.ts.map +1 -0
  113. package/dist/diagrams/er/ir.d.ts +28 -0
  114. package/dist/diagrams/er/ir.d.ts.map +1 -0
  115. package/dist/diagrams/er/layout.d.ts +12 -0
  116. package/dist/diagrams/er/layout.d.ts.map +1 -0
  117. package/dist/diagrams/flowchart/index.d.ts +5 -0
  118. package/dist/diagrams/flowchart/index.d.ts.map +1 -0
  119. package/dist/diagrams/flowchart/ir.d.ts +38 -0
  120. package/dist/diagrams/flowchart/ir.d.ts.map +1 -0
  121. package/dist/diagrams/flowchart/layout.d.ts +5 -0
  122. package/dist/diagrams/flowchart/layout.d.ts.map +1 -0
  123. package/dist/diagrams/gantt/index.d.ts +5 -0
  124. package/dist/diagrams/gantt/index.d.ts.map +1 -0
  125. package/dist/diagrams/gantt/ir.d.ts +25 -0
  126. package/dist/diagrams/gantt/ir.d.ts.map +1 -0
  127. package/dist/diagrams/gantt/layout.d.ts +12 -0
  128. package/dist/diagrams/gantt/layout.d.ts.map +1 -0
  129. package/dist/diagrams/gitgraph/index.d.ts +5 -0
  130. package/dist/diagrams/gitgraph/index.d.ts.map +1 -0
  131. package/dist/diagrams/gitgraph/ir.d.ts +31 -0
  132. package/dist/diagrams/gitgraph/ir.d.ts.map +1 -0
  133. package/dist/diagrams/gitgraph/layout.d.ts +12 -0
  134. package/dist/diagrams/gitgraph/layout.d.ts.map +1 -0
  135. package/dist/diagrams/journey/index.d.ts +5 -0
  136. package/dist/diagrams/journey/index.d.ts.map +1 -0
  137. package/dist/diagrams/journey/ir.d.ts +20 -0
  138. package/dist/diagrams/journey/ir.d.ts.map +1 -0
  139. package/dist/diagrams/journey/layout.d.ts +13 -0
  140. package/dist/diagrams/journey/layout.d.ts.map +1 -0
  141. package/dist/diagrams/kanban/index.d.ts +5 -0
  142. package/dist/diagrams/kanban/index.d.ts.map +1 -0
  143. package/dist/diagrams/kanban/ir.d.ts +18 -0
  144. package/dist/diagrams/kanban/ir.d.ts.map +1 -0
  145. package/dist/diagrams/kanban/layout.d.ts +12 -0
  146. package/dist/diagrams/kanban/layout.d.ts.map +1 -0
  147. package/dist/diagrams/mindmap/index.d.ts +5 -0
  148. package/dist/diagrams/mindmap/index.d.ts.map +1 -0
  149. package/dist/diagrams/mindmap/ir.d.ts +15 -0
  150. package/dist/diagrams/mindmap/ir.d.ts.map +1 -0
  151. package/dist/diagrams/mindmap/layout.d.ts +12 -0
  152. package/dist/diagrams/mindmap/layout.d.ts.map +1 -0
  153. package/dist/diagrams/packet/index.d.ts +5 -0
  154. package/dist/diagrams/packet/index.d.ts.map +1 -0
  155. package/dist/diagrams/packet/ir.d.ts +15 -0
  156. package/dist/diagrams/packet/ir.d.ts.map +1 -0
  157. package/dist/diagrams/packet/layout.d.ts +12 -0
  158. package/dist/diagrams/packet/layout.d.ts.map +1 -0
  159. package/dist/diagrams/pie/index.d.ts +5 -0
  160. package/dist/diagrams/pie/index.d.ts.map +1 -0
  161. package/dist/diagrams/pie/ir.d.ts +16 -0
  162. package/dist/diagrams/pie/ir.d.ts.map +1 -0
  163. package/dist/diagrams/pie/layout.d.ts +12 -0
  164. package/dist/diagrams/pie/layout.d.ts.map +1 -0
  165. package/dist/diagrams/poster/index.d.ts +5 -0
  166. package/dist/diagrams/poster/index.d.ts.map +1 -0
  167. package/dist/diagrams/poster/ir.d.ts +46 -0
  168. package/dist/diagrams/poster/ir.d.ts.map +1 -0
  169. package/dist/diagrams/poster/layout.d.ts +8 -0
  170. package/dist/diagrams/poster/layout.d.ts.map +1 -0
  171. package/dist/diagrams/quadrant/index.d.ts +5 -0
  172. package/dist/diagrams/quadrant/index.d.ts.map +1 -0
  173. package/dist/diagrams/quadrant/ir.d.ts +23 -0
  174. package/dist/diagrams/quadrant/ir.d.ts.map +1 -0
  175. package/dist/diagrams/quadrant/layout.d.ts +12 -0
  176. package/dist/diagrams/quadrant/layout.d.ts.map +1 -0
  177. package/dist/diagrams/radar/index.d.ts +5 -0
  178. package/dist/diagrams/radar/index.d.ts.map +1 -0
  179. package/dist/diagrams/radar/ir.d.ts +22 -0
  180. package/dist/diagrams/radar/ir.d.ts.map +1 -0
  181. package/dist/diagrams/radar/layout.d.ts +12 -0
  182. package/dist/diagrams/radar/layout.d.ts.map +1 -0
  183. package/dist/diagrams/requirement/index.d.ts +5 -0
  184. package/dist/diagrams/requirement/index.d.ts.map +1 -0
  185. package/dist/diagrams/requirement/ir.d.ts +25 -0
  186. package/dist/diagrams/requirement/ir.d.ts.map +1 -0
  187. package/dist/diagrams/requirement/layout.d.ts +12 -0
  188. package/dist/diagrams/requirement/layout.d.ts.map +1 -0
  189. package/dist/diagrams/sankey/index.d.ts +5 -0
  190. package/dist/diagrams/sankey/index.d.ts.map +1 -0
  191. package/dist/diagrams/sankey/ir.d.ts +15 -0
  192. package/dist/diagrams/sankey/ir.d.ts.map +1 -0
  193. package/dist/diagrams/sankey/layout.d.ts +12 -0
  194. package/dist/diagrams/sankey/layout.d.ts.map +1 -0
  195. package/dist/diagrams/sequence/index.d.ts +5 -0
  196. package/dist/diagrams/sequence/index.d.ts.map +1 -0
  197. package/dist/diagrams/sequence/ir.d.ts +47 -0
  198. package/dist/diagrams/sequence/ir.d.ts.map +1 -0
  199. package/dist/diagrams/sequence/layout.d.ts +13 -0
  200. package/dist/diagrams/sequence/layout.d.ts.map +1 -0
  201. package/dist/diagrams/state/index.d.ts +5 -0
  202. package/dist/diagrams/state/index.d.ts.map +1 -0
  203. package/dist/diagrams/state/ir.d.ts +28 -0
  204. package/dist/diagrams/state/ir.d.ts.map +1 -0
  205. package/dist/diagrams/state/layout.d.ts +12 -0
  206. package/dist/diagrams/state/layout.d.ts.map +1 -0
  207. package/dist/diagrams/timeline/index.d.ts +7 -0
  208. package/dist/diagrams/timeline/index.d.ts.map +1 -0
  209. package/dist/diagrams/timeline/ir.d.ts +47 -0
  210. package/dist/diagrams/timeline/ir.d.ts.map +1 -0
  211. package/dist/diagrams/timeline/layout.d.ts +5 -0
  212. package/dist/diagrams/timeline/layout.d.ts.map +1 -0
  213. package/dist/diagrams/timeline/numbered.d.ts +16 -0
  214. package/dist/diagrams/timeline/numbered.d.ts.map +1 -0
  215. package/dist/diagrams/timeline/roadmap.d.ts +18 -0
  216. package/dist/diagrams/timeline/roadmap.d.ts.map +1 -0
  217. package/dist/diagrams/timeline/serpentine.d.ts +20 -0
  218. package/dist/diagrams/timeline/serpentine.d.ts.map +1 -0
  219. package/dist/diagrams/timeline/shared.d.ts +37 -0
  220. package/dist/diagrams/timeline/shared.d.ts.map +1 -0
  221. package/dist/diagrams/timeline/timeline-columns.d.ts +19 -0
  222. package/dist/diagrams/timeline/timeline-columns.d.ts.map +1 -0
  223. package/dist/diagrams/timeline/vertical-spine.d.ts +21 -0
  224. package/dist/diagrams/timeline/vertical-spine.d.ts.map +1 -0
  225. package/dist/diagrams/topology/topology.d.ts +47 -0
  226. package/dist/diagrams/topology/topology.d.ts.map +1 -0
  227. package/dist/diagrams/xychart/index.d.ts +5 -0
  228. package/dist/diagrams/xychart/index.d.ts.map +1 -0
  229. package/dist/diagrams/xychart/ir.d.ts +21 -0
  230. package/dist/diagrams/xychart/ir.d.ts.map +1 -0
  231. package/dist/diagrams/xychart/layout.d.ts +12 -0
  232. package/dist/diagrams/xychart/layout.d.ts.map +1 -0
  233. package/dist/frontend/detect.d.ts +7 -0
  234. package/dist/frontend/detect.d.ts.map +1 -0
  235. package/dist/frontend/index.d.ts +44 -0
  236. package/dist/frontend/index.d.ts.map +1 -0
  237. package/dist/frontend/registry.d.ts +21 -0
  238. package/dist/frontend/registry.d.ts.map +1 -0
  239. package/dist/graph/connect.d.ts +39 -0
  240. package/dist/graph/connect.d.ts.map +1 -0
  241. package/dist/graph/layered.d.ts +43 -0
  242. package/dist/graph/layered.d.ts.map +1 -0
  243. package/dist/graph/tree.d.ts +41 -0
  244. package/dist/graph/tree.d.ts.map +1 -0
  245. package/dist/index.d.ts +9 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +41345 -0
  248. package/dist/index.js.map +7 -0
  249. package/dist/overlay/apply.d.ts +15 -0
  250. package/dist/overlay/apply.d.ts.map +1 -0
  251. package/dist/overlay/compiler.d.ts +10 -0
  252. package/dist/overlay/compiler.d.ts.map +1 -0
  253. package/dist/overlay/layout.d.ts +16 -0
  254. package/dist/overlay/layout.d.ts.map +1 -0
  255. package/dist/palette/categorical.d.ts +15 -0
  256. package/dist/palette/categorical.d.ts.map +1 -0
  257. package/dist/render/registry.d.ts +15 -0
  258. package/dist/render/registry.d.ts.map +1 -0
  259. package/dist/render/svg.d.ts +11 -0
  260. package/dist/render/svg.d.ts.map +1 -0
  261. package/dist/routing/registry.d.ts +16 -0
  262. package/dist/routing/registry.d.ts.map +1 -0
  263. package/dist/routing/router.d.ts +10 -0
  264. package/dist/routing/router.d.ts.map +1 -0
  265. package/dist/scene/build.d.ts +45 -0
  266. package/dist/scene/build.d.ts.map +1 -0
  267. package/dist/scene/strip.d.ts +39 -0
  268. package/dist/scene/strip.d.ts.map +1 -0
  269. package/dist/style/cost.d.ts +35 -0
  270. package/dist/style/cost.d.ts.map +1 -0
  271. package/dist/text/metrics.d.ts +19 -0
  272. package/dist/text/metrics.d.ts.map +1 -0
  273. package/dist/text/wrap.d.ts +21 -0
  274. package/dist/text/wrap.d.ts.map +1 -0
  275. package/dist/theme/preset.d.ts +29 -0
  276. package/dist/theme/preset.d.ts.map +1 -0
  277. package/dist/theme/resolver.d.ts +7 -0
  278. package/dist/theme/resolver.d.ts.map +1 -0
  279. package/dist/time/dates.d.ts +72 -0
  280. package/dist/time/dates.d.ts.map +1 -0
  281. package/dist/util/round.d.ts +12 -0
  282. package/dist/util/round.d.ts.map +1 -0
  283. package/package.json +42 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Anchors
3
+ *
4
+ * Contracts for the node-anchor registry: the mechanism that makes
5
+ * individual nodes addressable from outside their parent diagram.
6
+ *
7
+ * Every linkable diagram's layout engine produces a NodeAnchorRegistry
8
+ * alongside its Scene. The registry maps each node's logical ID to its
9
+ * bounding box and optional cardinal ports, expressed in the diagram's
10
+ * LOCAL coordinate space (before any composition-level translation/scaling).
11
+ *
12
+ * The composition layer (poster layout) transforms local anchors to
13
+ * poster-space coordinates, merges registries from child cells with
14
+ * path-prefixed keys, and publishes the merged result upward — enabling
15
+ * cross-diagram linking at any nesting depth.
16
+ *
17
+ * Dependency: primitives.ts
18
+ */
19
+ import type { Point, Rect } from './primitives.js';
20
+ import type { Scene } from './scene.js';
21
+ /** The four cardinal attachment sides of a node bounding box. */
22
+ export type CardinalSide = 'N' | 'S' | 'E' | 'W';
23
+ /**
24
+ * Explicit port positions on a node's boundary.
25
+ * If absent, the link layer derives port midpoints from the bounding box:
26
+ * N = (x + w/2, y)
27
+ * S = (x + w/2, y + h)
28
+ * E = (x + w, y + h/2)
29
+ * W = (x, y + h/2)
30
+ */
31
+ export type CardinalPorts = Partial<Record<CardinalSide, Point>>;
32
+ /**
33
+ * Anchor for a single node: bounding box in local diagram coordinates,
34
+ * plus optional explicit port attachment points.
35
+ *
36
+ * The bounding box is the axis-aligned rectangle that fully encloses
37
+ * the node's visual representation (shape + label + padding).
38
+ */
39
+ export interface NodeAnchor {
40
+ /** Bounding box in local diagram coordinates. */
41
+ readonly bounds: Rect;
42
+ /**
43
+ * Optional explicit port positions.
44
+ * When present, cross-link routing uses these instead of deriving
45
+ * midpoints from the bounding box edges.
46
+ */
47
+ readonly ports?: CardinalPorts;
48
+ }
49
+ /**
50
+ * Maps node IDs to their anchors in local diagram coordinates.
51
+ *
52
+ * For flat diagrams (flowchart, class, state, etc.):
53
+ * keys are the raw node IDs as authored: "pay", "db", "UserService"
54
+ *
55
+ * For hierarchical diagrams (poster with nested children):
56
+ * keys are dot-separated paths: "A1.pay", "B1.A1.db"
57
+ * Each level of nesting prepends the cell address.
58
+ *
59
+ * The registry is intentionally a plain Record for JSON serialisability
60
+ * and O(1) lookup. Iteration order is not guaranteed.
61
+ */
62
+ export type NodeAnchorRegistry = Readonly<Record<string, NodeAnchor>>;
63
+ /**
64
+ * A port position on a node wall that is already in use by an edge rendered
65
+ * within a diagram cell (intra) or by another cross-link (inter).
66
+ *
67
+ * The cross-link routing engine uses these to avoid stacking connectors
68
+ * at the same wall position. Intra-diagram ports carry a softer penalty
69
+ * than inter-crosslink ports so the global cost function can override them
70
+ * when necessary.
71
+ */
72
+ export interface OccupiedPort {
73
+ /** Prefixed node key (same format as NodeAnchorRegistry keys). */
74
+ readonly nodeKey: string;
75
+ /** Which wall the port is on. */
76
+ readonly wall: CardinalSide;
77
+ /**
78
+ * Fractional position along the wall (0 = start, 1 = end).
79
+ * N/S walls: 0 = left edge, 1 = right edge.
80
+ * E/W walls: 0 = top edge, 1 = bottom edge.
81
+ */
82
+ readonly t: number;
83
+ /**
84
+ * Origin of the occupancy.
85
+ * 'intra' — edge produced by the cell's own diagram layout pass.
86
+ * 'inter' — cross-link committed by the cross-link routing engine.
87
+ */
88
+ readonly source: 'intra' | 'inter';
89
+ }
90
+ /**
91
+ * The extended return type of a diagram layout pass.
92
+ *
93
+ * All diagram layout engines return LayoutResult instead of bare Scene.
94
+ * This carries the renderable scene AND the anchor registry for
95
+ * cross-diagram linking.
96
+ *
97
+ * Non-linkable diagrams (pie, timeline, sankey, etc.) return an empty
98
+ * registry {}. Links referencing their nodes degrade gracefully (WARN + skip).
99
+ */
100
+ export interface LayoutResult {
101
+ /** The fully resolved, renderable scene. */
102
+ readonly scene: Scene;
103
+ /**
104
+ * Node anchors in local diagram coordinates.
105
+ * Empty {} for non-linkable diagram types.
106
+ */
107
+ readonly anchors: NodeAnchorRegistry;
108
+ /**
109
+ * Port positions occupied by edges produced during this layout pass.
110
+ * The cross-link routing engine uses these to avoid stacking connectors
111
+ * on top of existing intra-diagram edges.
112
+ * Empty or absent for non-linkable diagram types.
113
+ */
114
+ readonly occupiedPorts?: readonly OccupiedPort[];
115
+ }
116
+ /**
117
+ * A soft layout constraint injected by the composition layer to bias
118
+ * a node's placement toward a specific boundary edge.
119
+ *
120
+ * Port hints enable Phase 2 negotiation: when a cross-link route has
121
+ * poor quality (crosses cells, excessive bends), the composition layer
122
+ * re-invokes the child layout with hints, nudging connected nodes
123
+ * toward the boundary facing their cross-link target.
124
+ *
125
+ * Hints are advisory — the layout engine should treat them as tie-breakers,
126
+ * not hard constraints. A hint with strength 0 is ignored; strength 1
127
+ * means "place this node as close to the specified side as possible
128
+ * without violating internal graph constraints."
129
+ */
130
+ export interface PortHint {
131
+ /** The node ID to bias. */
132
+ readonly nodeId: string;
133
+ /** Which boundary edge to prefer. */
134
+ readonly preferredSide: CardinalSide;
135
+ /** Bias strength in [0, 1]. Default interpretation: 0 = ignore, 1 = maximum bias. */
136
+ readonly strength: number;
137
+ }
138
+ /**
139
+ * Optional layout constraints passed to a diagram layout engine
140
+ * during negotiation rounds.
141
+ *
142
+ * The base layout() call receives no options (first pass).
143
+ * Subsequent negotiation passes may include port hints derived from
144
+ * cross-link quality analysis.
145
+ */
146
+ export interface LayoutOptions {
147
+ /** Port placement hints from the composition layer. */
148
+ readonly portHints?: readonly PortHint[];
149
+ }
150
+ //# sourceMappingURL=anchors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchors.d.ts","sourceRoot":"","sources":["../../../../src/contracts/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AAIjE;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC;AAID;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAMtE;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC1C"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Cross-Link
3
+ *
4
+ * Contracts for cross-diagram linking in poster compositions.
5
+ *
6
+ * Two constructs:
7
+ * - CrossLink: a single directed/undirected edge between nodes in
8
+ * different cells of a poster.
9
+ * - Trace: a named, ordered, optionally-typed multi-hop path of
10
+ * cross-links representing a logical thread (user journey,
11
+ * requirement traceability, distributed request path).
12
+ *
13
+ * Cross-links are presentation-layer assertions on the composition.
14
+ * They do NOT modify any child diagram's IR or Scene — each cell
15
+ * compiles as if links don't exist. All resolution happens at
16
+ * composition time, after every cell has produced its LayoutResult.
17
+ *
18
+ * Dependency: primitives.ts, anchors.ts
19
+ */
20
+ import type { Point, Color } from './primitives.js';
21
+ import type { CardinalSide, NodeAnchor } from './anchors.js';
22
+ import type { RouteStyle } from './routing.js';
23
+ /**
24
+ * Address of a node across poster nesting levels.
25
+ *
26
+ * A flat poster uses a single-segment path: ["A1", "pay"]
27
+ * → cell A1, node "pay"
28
+ *
29
+ * A nested poster uses multi-segment paths: ["A1", "B1", "db"]
30
+ * → cell A1 (which is itself a poster), cell B1 within it, node "db"
31
+ *
32
+ * The last segment is always the node ID.
33
+ * All preceding segments are cell addresses traversed from the poster
34
+ * where the link is declared.
35
+ */
36
+ export interface NodeAddress {
37
+ /** Ordered cell path from the declaring poster to the target cell. */
38
+ readonly cellPath: readonly string[];
39
+ /** Node ID within the target cell's diagram. */
40
+ readonly nodeId: string;
41
+ }
42
+ /** Visual style of a cross-diagram edge. */
43
+ export type CrossLinkEdgeStyle = 'solid' | 'dashed' | 'dotted';
44
+ /** Direction of a cross-diagram edge. */
45
+ export type CrossLinkDirection = 'directed' | 'undirected' | 'bidirectional';
46
+ /**
47
+ * A single cross-diagram edge between two nodes in different cells.
48
+ * This is the primitive — traces desugar into ordered sequences of these.
49
+ */
50
+ export interface CrossLink {
51
+ /** Source endpoint address. */
52
+ readonly from: NodeAddress;
53
+ /** Target endpoint address. */
54
+ readonly to: NodeAddress;
55
+ readonly direction: CrossLinkDirection;
56
+ readonly style: CrossLinkEdgeStyle;
57
+ /** Optional label rendered at the route midpoint. */
58
+ readonly label?: string;
59
+ /**
60
+ * Geometric routing style for this edge.
61
+ * Defaults to 'orthogonal' when omitted.
62
+ */
63
+ readonly routing?: RouteStyle;
64
+ /**
65
+ * Optional hint for which wall to exit from the source node.
66
+ * When set, the routing engine skips all other srcWall candidates.
67
+ */
68
+ readonly exitWall?: CardinalSide;
69
+ /**
70
+ * Optional hint for which wall to enter the destination node.
71
+ * When set, the routing engine skips all other dstWall candidates.
72
+ */
73
+ readonly entryWall?: CardinalSide;
74
+ /**
75
+ * Animation applied to the rendered connector.
76
+ *
77
+ * 'march' — marching ants (stroke-dashoffset cycle). Only visible when
78
+ * the edge style is dashed or dotted; silently ignored on solid.
79
+ * 'particle' — a dot travels along the path. Works on any edge style.
80
+ * 'none' — explicitly suppresses the default animation for this edge.
81
+ *
82
+ * When omitted the renderer applies defaults:
83
+ * dashed → 'march', dotted → 'march', solid → no animation.
84
+ */
85
+ readonly animation?: 'march' | 'particle' | 'none';
86
+ /**
87
+ * If this link is part of a trace, the trace's ID.
88
+ * Used to apply consistent styling (colour, grouping) across trace members.
89
+ */
90
+ readonly traceId?: string;
91
+ /**
92
+ * Optional property bag for future per-link overrides (tension, color, etc.).
93
+ * Parsed from `{ key: value }` blocks in the syntax.
94
+ */
95
+ readonly props?: Readonly<Record<string, string | number>>;
96
+ }
97
+ /**
98
+ * Semantic type of a trace — what relationship the hops represent.
99
+ * Extensible; these are the built-in vocabulary from the design spec.
100
+ */
101
+ export type TraceType = 'satisfies' | 'triggers' | 'calls' | 'reads' | 'writes' | 'extends' | 'custom';
102
+ /**
103
+ * A named, ordered, optionally-typed multi-hop path of cross-diagram links.
104
+ *
105
+ * Traces desugar to atomic CrossLink[]s at composition time.
106
+ * The TraceRecord groups them under a name for consistent styling,
107
+ * legend display, and agent addressability.
108
+ */
109
+ export interface TraceRecord {
110
+ /** Unique trace ID (auto-generated or author-specified). */
111
+ readonly id: string;
112
+ /** Human-readable name displayed in the legend. */
113
+ readonly name: string;
114
+ /** Optional semantic type governing the trace legend pill label. */
115
+ readonly type?: TraceType;
116
+ /**
117
+ * Ordered hop endpoints. Length N produces N-1 atomic links:
118
+ * hops[0]→hops[1], hops[1]→hops[2], …, hops[N-2]→hops[N-1]
119
+ */
120
+ readonly hops: readonly NodeAddress[];
121
+ /** Resolved colour assigned at composition time from the categorical palette. */
122
+ readonly color?: Color;
123
+ }
124
+ /**
125
+ * A cross-link with both endpoints resolved to poster-space coordinates.
126
+ * Produced by the resolution pass; consumed by the routing pass.
127
+ */
128
+ export interface ResolvedCrossLink {
129
+ readonly link: CrossLink;
130
+ /** Source anchor in poster coordinates. */
131
+ readonly fromAnchor: NodeAnchor;
132
+ /** Target anchor in poster coordinates. */
133
+ readonly toAnchor: NodeAnchor;
134
+ /** Selected port pair (minimises distance). */
135
+ readonly fromPort: Point;
136
+ readonly toPort: Point;
137
+ readonly fromSide: CardinalSide;
138
+ readonly toSide: CardinalSide;
139
+ }
140
+ /**
141
+ * Quality metrics for a computed cross-link route.
142
+ * Used by Phase 2 negotiation to decide whether to perturb layout.
143
+ */
144
+ export interface RouteQuality {
145
+ /** Number of 90° bends in the route. */
146
+ readonly bends: number;
147
+ /** Total route length in px. */
148
+ readonly length: number;
149
+ /** Number of cell bounding boxes the route crosses through. */
150
+ readonly cellCrossings: number;
151
+ /**
152
+ * Ratio of actual route length to straight-line distance.
153
+ * 1.0 = perfectly direct. Higher = more detour.
154
+ */
155
+ readonly detourRatio: number;
156
+ /** Overall quality verdict. */
157
+ readonly acceptable: boolean;
158
+ }
159
+ /**
160
+ * A perturbation proposal generated by the quality analyser.
161
+ * The composition engine evaluates proposals and applies the best ones.
162
+ */
163
+ export type PerturbationKind = 'expand-gutter' | 'swap-cells' | 'add-routing-bus' | 'port-hint';
164
+ export interface Perturbation {
165
+ readonly kind: PerturbationKind;
166
+ /** Which cross-link triggered this proposal. */
167
+ readonly linkIndex: number;
168
+ /** Perturbation-specific payload. */
169
+ readonly payload: Readonly<Record<string, unknown>>;
170
+ }
171
+ //# sourceMappingURL=crosslink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crosslink.d.ts","sourceRoot":"","sources":["../../../../src/contracts/crosslink.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Diagram
3
+ *
4
+ * The contract every diagram type must satisfy.
5
+ *
6
+ * Parsing and layout are defined as separate interfaces.
7
+ * This segregation matters:
8
+ *
9
+ * DiagramParser<IR> — knows how to turn text into an IR.
10
+ * Testable in isolation; no theme required.
11
+ *
12
+ * DiagramLayoutEngine<IR> — knows how to turn an IR into a Scene.
13
+ * Testable in isolation with a fixture IR.
14
+ *
15
+ * DiagramModule<IR> — the full module: composes both.
16
+ * This is the type diagram directories export.
17
+ *
18
+ * Callers that only need to parse (e.g. a linter, a validator) depend on
19
+ * DiagramParser. Callers that only need to render a pre-built IR (e.g. a
20
+ * server receiving JSON) depend on DiagramLayoutEngine. The full pipeline
21
+ * depends on DiagramModule.
22
+ */
23
+ import type { ResolvedTheme, ThemeInput } from './theme.js';
24
+ import type { RawOverlay } from './overlay.js';
25
+ import type { LayoutResult, LayoutOptions } from './anchors.js';
26
+ /**
27
+ * The minimum shape every diagram IR must satisfy.
28
+ *
29
+ * All diagram-specific IR interfaces extend BaseIR. This ensures:
30
+ * - Every IR carries uniform metadata (version, title, etc.)
31
+ * - Every IR can carry overlays (notes, legends) without the pipeline
32
+ * needing to know the concrete diagram type.
33
+ * - Every IR can express per-diagram theme overrides parsed from
34
+ * frontmatter, applied by the pipeline before layout() is called.
35
+ */
36
+ export interface BaseIR {
37
+ readonly version: string;
38
+ readonly metadata: {
39
+ readonly [key: string]: unknown;
40
+ };
41
+ /** Overlays declared in the diagram source (notes, legends). */
42
+ readonly overlays?: readonly RawOverlay[];
43
+ /**
44
+ * Per-diagram theme overrides parsed from frontmatter.
45
+ * Applied on top of global theme + module defaults before layout().
46
+ */
47
+ readonly themeOverride?: ThemeInput;
48
+ }
49
+ export interface DiagramParser<IR extends BaseIR> {
50
+ /**
51
+ * Parse Mermaid-syntax text into the canonical IR.
52
+ * Throws a descriptive error on invalid input.
53
+ */
54
+ parseMermaid(input: string): IR;
55
+ /**
56
+ * Validate and parse YAML text into the canonical IR.
57
+ * Throws a descriptive error on invalid or schema-violating input.
58
+ */
59
+ parseYaml(input: string): IR;
60
+ }
61
+ export interface DiagramLayoutEngine<IR extends BaseIR> {
62
+ /**
63
+ * Transform a validated IR into a fully resolved, renderable LayoutResult.
64
+ *
65
+ * Returns both the renderable Scene and the node anchor registry.
66
+ * Non-linkable diagram types return an empty anchors registry {}.
67
+ *
68
+ * Synchronous: every Triton layout engine computes its geometry in-process
69
+ * with no deferred work (no font-metric I/O, no WASM, no fetching). Keeping
70
+ * layout sync lets the frontend expose a synchronous render path
71
+ * (renderSync) for hosts that need it (e.g. the markdown-it preview plugin),
72
+ * while the async render() wrapper remains for existing callers.
73
+ *
74
+ * The returned Scene is complete — all overlay geometry has been
75
+ * incorporated into Scene.elements before it is returned.
76
+ *
77
+ * @param options - Optional layout constraints (port hints) from the
78
+ * composition layer during negotiation passes. Absent on first pass.
79
+ */
80
+ layout(ir: IR, theme: ResolvedTheme, options?: LayoutOptions): LayoutResult;
81
+ }
82
+ /**
83
+ * The complete diagram module interface — parsing and layout together.
84
+ * Every src/diagrams/<type>/index.ts exports a value satisfying this.
85
+ */
86
+ export interface DiagramModule<IR extends BaseIR> extends DiagramParser<IR>, DiagramLayoutEngine<IR> {
87
+ /**
88
+ * Optional per-diagram theme defaults.
89
+ * Applied on top of the global theme but below ir.themeOverride:
90
+ *
91
+ * result = global ← defaultThemeOverride ← ir.themeOverride
92
+ */
93
+ readonly defaultThemeOverride?: ThemeInput;
94
+ }
95
+ /**
96
+ * The exhaustive set of diagram types recognised by Triton.
97
+ *
98
+ * This is the single source of truth for valid diagram kind strings.
99
+ * The frontend detector, the CLI, and the API all narrow to this type.
100
+ *
101
+ * Adding a new diagram type requires adding it here first — before any
102
+ * implementation exists. This makes the set of intended diagrams explicit.
103
+ */
104
+ export type DiagramKind = 'flowchart' | 'timeline' | 'poster' | 'sequence' | 'mindmap' | 'state' | 'class' | 'er' | 'gantt' | 'c4' | 'sankey' | 'kanban' | 'requirement' | 'gitgraph' | 'packet' | 'block' | 'architecture' | 'pie' | 'xychart' | 'quadrant' | 'radar' | 'journey' | 'tree' | 'plan' | 'avl' | 'rbtree' | 'btree' | 'radix' | 'segtree' | 'heap' | 'array' | 'linkedlist' | 'memory' | 'page' | 'queue' | 'cqueue' | 'deque' | 'pqueue' | 'stack' | 'hashmap' | 'matrix' | 'trie' | 'nodegraph' | 'unionfind' | 'topology';
105
+ /** The two input formats Triton accepts. */
106
+ export type InputFormat = 'mermaid' | 'yaml';
107
+ //# sourceMappingURL=diagram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../../src/contracts/diagram.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE;;;;;;;;;GASG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACvD,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC;CACrC;AAID,MAAM,WAAW,aAAa,CAAC,EAAE,SAAS,MAAM;IAC9C;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC;IAEhC;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC;CAC9B;AAID,MAAM,WAAW,mBAAmB,CAAC,EAAE,SAAS,MAAM;IACpD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CAC7E;AAID;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,EAAE,SAAS,MAAM,CAAE,SAAQ,aAAa,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,EAAE,CAAC;IAClG;;;;;OAKG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,UAAU,CAAC;CAC5C;AAID;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GACnB,WAAW,GACX,UAAU,GACV,QAAQ,GACR,UAAU,GACV,SAAS,GACT,OAAO,GACP,OAAO,GACP,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,UAAU,GACV,QAAQ,GACR,OAAO,GACP,cAAc,GACd,KAAK,GACL,SAAS,GACT,UAAU,GACV,OAAO,GACP,SAAS,GACT,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,SAAS,GACT,MAAM,GACN,OAAO,GACP,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,SAAS,GACT,QAAQ,GACR,MAAM,GACN,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAEf,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Contracts — barrel re-export.
3
+ *
4
+ * Import everything from here. Do not import directly from sub-files
5
+ * outside the contracts/ directory.
6
+ *
7
+ * Dependency order (each file imports only from files above it):
8
+ *
9
+ * primitives (no deps)
10
+ * scene ← primitives
11
+ * theme ← primitives
12
+ * overlay ← primitives
13
+ * routing ← primitives
14
+ * result (no deps)
15
+ * renderer ← scene
16
+ * diagram ← scene, theme, overlay
17
+ */
18
+ export type { Point, Size, Rect, Color, FontFamily, TextAnchor, FontWeight, } from './primitives.js';
19
+ export type { SceneRect, SceneCircle, ScenePath, SceneText, SceneGroup, SceneElement, Scene, } from './scene.js';
20
+ export type { ThemePalette, ThemeTypography, ThemeSpacing, ThemeEdges, ThemePanel, ResolvedTheme, ThemeInput, } from './theme.js';
21
+ export type { RawNote, RawLegend, RawOverlay, LegendCorner, LegendEntry, Legend, Annotation, CompiledOverlays, } from './overlay.js';
22
+ export type { RouteStyle, PortDirection, RouteRequest, Route, Router, } from './routing.js';
23
+ export type { DiagramParser, DiagramLayoutEngine, DiagramModule, DiagramKind, InputFormat, BaseIR, } from './diagram.js';
24
+ export type { DiagramErrorCode, DiagramError, Result, } from './result.js';
25
+ export { ok, err } from './result.js';
26
+ export type { Renderer } from './renderer.js';
27
+ export type { CardinalSide, CardinalPorts, NodeAnchor, NodeAnchorRegistry, OccupiedPort, LayoutResult, PortHint, LayoutOptions, } from './anchors.js';
28
+ export type { NodeAddress, CrossLinkEdgeStyle, CrossLinkDirection, CrossLink, TraceType, TraceRecord, ResolvedCrossLink, RouteQuality, PerturbationKind, Perturbation, } from './crosslink.js';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EACV,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,OAAO,EACP,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EACX,MAAM,EACN,UAAU,EACV,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,KAAK,EACL,MAAM,GACP,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,WAAW,EACX,MAAM,GACP,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEtC,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,YAAY,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Overlay
3
+ *
4
+ * Contracts for diagram annotations and legends.
5
+ *
6
+ * This file defines two layers:
7
+ *
8
+ * RAW layer — types emitted by PEG grammars. These are structural captures
9
+ * of the overlay syntax, not yet positioned or resolved.
10
+ *
11
+ * RESOLVED layer — types consumed by layout engines and the overlay pipeline.
12
+ * These have fully specified positions and anchor references.
13
+ *
14
+ * The separation matters: grammars produce Raw types; the overlay compiler
15
+ * (implementation, not defined here) converts Raw → Resolved; layout engines
16
+ * incorporate Resolved overlays into the final Scene geometry.
17
+ *
18
+ * Neither layer appears on the Scene type — overlays are fully resolved into
19
+ * SceneElement[]s before a Scene is returned from layout().
20
+ */
21
+ import type { Point } from './primitives.js';
22
+ /**
23
+ * A note/annotation directive as captured verbatim by a grammar rule.
24
+ * The target is an element label or ID — not yet a screen coordinate.
25
+ */
26
+ export interface RawNote {
27
+ readonly type: 'note';
28
+ readonly text: string;
29
+ /** Element ID or label this note is anchored to. */
30
+ readonly target: string;
31
+ /** Optional pixel offset from the anchor, e.g. to avoid overlap. */
32
+ readonly offset?: {
33
+ readonly dx: number;
34
+ readonly dy: number;
35
+ };
36
+ }
37
+ /**
38
+ * A legend block directive as captured verbatim by a grammar rule.
39
+ * Corner is a raw string — the overlay compiler validates and narrows it.
40
+ */
41
+ export interface RawLegend {
42
+ readonly type: 'legend';
43
+ readonly corner: string;
44
+ readonly title?: string;
45
+ readonly entries: ReadonlyArray<{
46
+ readonly key: string;
47
+ readonly value: string;
48
+ }>;
49
+ }
50
+ /** Union of every overlay directive a grammar can emit. */
51
+ export type RawOverlay = RawNote | RawLegend;
52
+ /** The four corners a legend may occupy. */
53
+ export type LegendCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
54
+ export interface LegendEntry {
55
+ readonly key: string;
56
+ readonly value: string;
57
+ }
58
+ /**
59
+ * A resolved legend block — position is determined by the layout engine
60
+ * relative to the diagram's viewBox using the corner property.
61
+ */
62
+ export interface Legend {
63
+ readonly title?: string;
64
+ readonly entries: ReadonlyArray<LegendEntry>;
65
+ readonly corner: LegendCorner;
66
+ /** Width override in px. Auto-sized to content if absent. */
67
+ readonly width?: number;
68
+ }
69
+ /**
70
+ * A resolved annotation — a callout box with a connector to an anchor.
71
+ *
72
+ * Position is the top-left of the callout box.
73
+ * Anchor is either a resolved screen point or an element group ID that
74
+ * the overlay layout engine will resolve at render time.
75
+ */
76
+ export interface Annotation {
77
+ readonly id: string;
78
+ readonly text: string;
79
+ /** Top-left corner of the annotation box in diagram coordinates. */
80
+ readonly position: Point;
81
+ /** What the connector line points to. */
82
+ readonly anchor: {
83
+ readonly elementId: string;
84
+ } | {
85
+ readonly point: Point;
86
+ };
87
+ /** Width override in px. Auto-sized to content if absent. */
88
+ readonly width?: number;
89
+ }
90
+ /**
91
+ * The fully compiled set of overlays for a diagram.
92
+ * Produced by the overlay compiler from RawOverlay[].
93
+ */
94
+ export interface CompiledOverlays {
95
+ readonly annotations: ReadonlyArray<Annotation>;
96
+ readonly legend?: Legend;
97
+ }
98
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../../src/contracts/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnF;AAED,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAI7C,4CAA4C;AAC5C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;AAErF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC;IAC5E,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Primitives
3
+ *
4
+ * Foundational geometric and visual value types.
5
+ * These are the atoms of the rendering coordinate system.
6
+ *
7
+ * Rules for this file:
8
+ * - No imports from anywhere in the project.
9
+ * - No functions, classes, or values — types only.
10
+ * - Every other contract file may import from here; nothing here imports upward.
11
+ */
12
+ /** A 2D point in SVG coordinate space (origin top-left, y grows downward). */
13
+ export interface Point {
14
+ readonly x: number;
15
+ readonly y: number;
16
+ }
17
+ /** A width × height pair. */
18
+ export interface Size {
19
+ readonly width: number;
20
+ readonly height: number;
21
+ }
22
+ /**
23
+ * An axis-aligned bounding box — position + size combined.
24
+ * Extends both Point and Size so callers can destructure either way.
25
+ */
26
+ export interface Rect extends Point, Size {
27
+ }
28
+ /**
29
+ * A CSS color string — hex, rgb(), hsl(), named color, etc.
30
+ * Opaque alias: the type system trusts the caller to provide a valid value.
31
+ */
32
+ export type Color = string;
33
+ /**
34
+ * A CSS font-family string (may include fallback stack).
35
+ * Opaque alias: conveys intent without runtime validation overhead.
36
+ */
37
+ export type FontFamily = string;
38
+ /** Horizontal text alignment in SVG terms. */
39
+ export type TextAnchor = 'start' | 'middle' | 'end';
40
+ /** Font weight values supported by the renderer. */
41
+ export type FontWeight = 'normal' | 'bold';
42
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../../../src/contracts/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,8EAA8E;AAC9E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,6BAA6B;AAC7B,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,IAAK,SAAQ,KAAK,EAAE,IAAI;CAAG;AAI5C;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEpD,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Renderer
3
+ *
4
+ * Output-format contract. A Renderer transforms a resolved Scene into a
5
+ * specific output format (SVG string, PNG buffer, Canvas draw calls…).
6
+ *
7
+ * Renderers are registered by name via the render registry. The default
8
+ * renderer is 'svg'. Third-party output formats register themselves with
9
+ * registerRenderer().
10
+ *
11
+ * Renderers know nothing about diagram types, themes, or IR shapes — they
12
+ * consume only Scene, which is the universal render-ready representation.
13
+ */
14
+ import type { Scene } from './scene.js';
15
+ export interface Renderer<Output = string> {
16
+ /** Unique name used for renderer lookup, e.g. 'svg', 'png', 'canvas'. */
17
+ readonly name: string;
18
+ /** Transform a fully resolved Scene into the target output format. */
19
+ render(scene: Scene): Output;
20
+ }
21
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/contracts/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,QAAQ,CAAC,MAAM,GAAG,MAAM;IACvC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,sEAAsE;IACtE,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CAC9B"}