@zyro-sec/merman 1.0.2 → 1.0.3

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 (91) hide show
  1. package/package.json +2 -2
  2. package/script/layout-audit.ts +98 -98
  3. package/src/core/canvas.ts +228 -228
  4. package/src/core/color/style.ts +56 -56
  5. package/src/core/drawing.ts +301 -301
  6. package/src/core/geometry.ts +347 -347
  7. package/src/core/mermaid.ts +38 -38
  8. package/src/core/render-grid.ts +51 -51
  9. package/src/core/spatial.ts +243 -243
  10. package/src/core/text-lines.ts +32 -32
  11. package/src/core/text.ts +44 -44
  12. package/src/detect.ts +17 -17
  13. package/src/diagnostics.ts +16 -16
  14. package/src/flowchart/drawing.ts +340 -340
  15. package/src/flowchart/labels.ts +144 -144
  16. package/src/flowchart/layout.ts +1427 -1427
  17. package/src/flowchart/options.ts +12 -12
  18. package/src/flowchart/parser.ts +467 -467
  19. package/src/flowchart/render.ts +10 -10
  20. package/src/flowchart/routing.ts +1542 -1542
  21. package/src/flowchart/style.ts +79 -79
  22. package/src/flowchart/types.ts +65 -65
  23. package/src/gantt/diagram.ts +8 -8
  24. package/src/gantt/drawing.ts +191 -191
  25. package/src/gantt/parser.ts +161 -161
  26. package/src/gantt/render-grid.ts +17 -17
  27. package/src/gantt/style.ts +36 -36
  28. package/src/gantt/types.ts +44 -44
  29. package/src/gitgraph/diagram.ts +8 -8
  30. package/src/gitgraph/drawing.ts +234 -234
  31. package/src/gitgraph/parser.ts +219 -219
  32. package/src/gitgraph/render-grid.ts +17 -17
  33. package/src/gitgraph/style.ts +37 -37
  34. package/src/gitgraph/types.ts +36 -36
  35. package/src/markdown.ts +336 -336
  36. package/src/palette.ts +75 -75
  37. package/src/plugin.ts +15 -15
  38. package/src/sequence/diagram.ts +8 -8
  39. package/src/sequence/drawing.ts +287 -287
  40. package/src/sequence/options.ts +8 -8
  41. package/src/sequence/parser.ts +282 -282
  42. package/src/sequence/placement.ts +684 -684
  43. package/src/sequence/render-grid.ts +22 -22
  44. package/src/sequence/style.ts +81 -81
  45. package/src/sequence/types.ts +74 -74
  46. package/src/state/diagram.ts +8 -8
  47. package/src/state/drawing.ts +360 -360
  48. package/src/state/endpoint.ts +15 -15
  49. package/src/state/layout.ts +1134 -1134
  50. package/src/state/note.ts +59 -59
  51. package/src/state/options.ts +11 -11
  52. package/src/state/parser.ts +224 -224
  53. package/src/state/render-grid.ts +22 -22
  54. package/src/state/routing.ts +1522 -1522
  55. package/src/state/search.ts +103 -103
  56. package/src/state/style.ts +52 -52
  57. package/src/state/types.ts +63 -63
  58. package/src/state/visible-model.ts +77 -77
  59. package/src/test/diagram.ts +32 -32
  60. package/src/test/layout-audit/fixtures.ts +538 -538
  61. package/src/test/layout-audit/harness.ts +522 -522
  62. package/src/timeline/diagram.ts +8 -8
  63. package/src/timeline/drawing.ts +109 -109
  64. package/src/timeline/parser.ts +119 -119
  65. package/src/timeline/render-grid.ts +17 -17
  66. package/src/timeline/style.ts +36 -36
  67. package/src/timeline/types.ts +31 -31
  68. package/tsconfig.json +10 -10
  69. package/src/core/canvas.test.ts +0 -203
  70. package/src/core/color/style.test.ts +0 -24
  71. package/src/core/drawing.test.ts +0 -116
  72. package/src/core/geometry.test.ts +0 -112
  73. package/src/core/spatial.test.ts +0 -87
  74. package/src/core/text.test.ts +0 -33
  75. package/src/flowchart/flowchart.test.ts +0 -2800
  76. package/src/flowchart/labels.test.ts +0 -127
  77. package/src/flowchart/routing.test.ts +0 -368
  78. package/src/gantt/diagram.test.ts +0 -124
  79. package/src/gitgraph/diagram.test.ts +0 -183
  80. package/src/layout-audit.test.ts +0 -92
  81. package/src/palette.test.ts +0 -103
  82. package/src/sequence/diagram.test.ts +0 -757
  83. package/src/sequence/placement.test.ts +0 -219
  84. package/src/state/diagram.test.ts +0 -1386
  85. package/src/state/layout.test.ts +0 -314
  86. package/src/state/routing.test.ts +0 -693
  87. package/src/state/style.test.ts +0 -113
  88. package/src/state/visible-model.test.ts +0 -84
  89. package/src/test/diagnostics.test.ts +0 -129
  90. package/src/test/markdown.test.ts +0 -474
  91. package/src/timeline/diagram.test.ts +0 -188
@@ -1,234 +1,234 @@
1
- import { DiagramCanvas } from "../core/canvas.js"
2
- import { diagramTextWidth } from "../core/text.js"
3
- import type { GitGraphGrid } from "./render-grid.js"
4
- import type { GitGraphCellStyle, GitGraphCommit, GitGraphDiagram, GitGraphDiagramRenderOptions } from "./types.js"
5
-
6
- interface BranchSpan {
7
- first: number
8
- last: number
9
- }
10
-
11
- interface Connections {
12
- up?: boolean
13
- down?: boolean
14
- left?: boolean
15
- right?: boolean
16
- style: GitGraphCellStyle
17
- }
18
-
19
- const LANE_WIDTH = 2
20
- const LABEL_GAP = 2
21
-
22
- export function drawGitGraphDiagramGrid(
23
- diagram: GitGraphDiagram,
24
- _options: GitGraphDiagramRenderOptions = {},
25
- ): GitGraphGrid {
26
- if (diagram.commits.length === 0) return new DiagramCanvas(0, 0)
27
- const laneByBranch = new Map(diagram.branches.map((branch, index) => [branch.name, index]))
28
- const commitById = new Map(diagram.commits.map((commit) => [commit.id, commit]))
29
- const spans = branchSpans(diagram, commitById)
30
- const heads = branchHeads(diagram)
31
- const graphWidth = (diagram.branches.length - 1) * LANE_WIDTH + 1
32
- let labelWidth = 0
33
- for (const commit of diagram.commits) labelWidth = Math.max(labelWidth, diagramTextWidth(commitLabel(commit, heads)))
34
- const forks = diagram.commits.map((commit) => isFork(commit, laneByBranch, commitById))
35
- const height = diagram.commits.length + forks.filter(Boolean).length
36
- const grid: GitGraphGrid = new DiagramCanvas(graphWidth + LABEL_GAP + labelWidth, height)
37
-
38
- let row = 0
39
- diagram.commits.forEach((commit, index) => {
40
- if (forks[index]) {
41
- drawTransitionRow(grid, spans, laneByBranch, commitById, commit, index, row)
42
- row += 1
43
- }
44
- drawCommitRow(grid, diagram, spans, laneByBranch, commitById, commit, index, row)
45
- grid.setText(graphWidth + LABEL_GAP, row, commitLabel(commit, heads), "label")
46
- row += 1
47
- })
48
- return grid
49
- }
50
-
51
- function drawTransitionRow(
52
- grid: GitGraphGrid,
53
- spans: Map<string, BranchSpan>,
54
- laneByBranch: Map<string, number>,
55
- commitById: Map<string, GitGraphCommit>,
56
- commit: GitGraphCommit,
57
- index: number,
58
- y: number,
59
- ): void {
60
- const cells = new Map<number, Connections>()
61
- for (const [branch, span] of spans) {
62
- if (span.first >= index || span.last < index) continue
63
- const lane = laneByBranch.get(branch)!
64
- connect(cells, lane * LANE_WIDTH, { up: true, down: true }, branchStyle(lane))
65
- }
66
-
67
- const lane = laneByBranch.get(commit.branch)!
68
- const firstParent = commit.parents[0] === undefined ? undefined : commitById.get(commit.parents[0])
69
- if (firstParent && firstParent.branch !== commit.branch) {
70
- const parentLane = laneByBranch.get(firstParent.branch)!
71
- connectHorizontal(
72
- cells,
73
- parentLane,
74
- lane,
75
- { sourceUp: true, sourceDown: true, targetDown: true },
76
- branchStyle(lane),
77
- )
78
- }
79
- paintConnections(grid, cells, y)
80
- }
81
-
82
- function drawCommitRow(
83
- grid: GitGraphGrid,
84
- diagram: GitGraphDiagram,
85
- spans: Map<string, BranchSpan>,
86
- laneByBranch: Map<string, number>,
87
- commitById: Map<string, GitGraphCommit>,
88
- commit: GitGraphCommit,
89
- index: number,
90
- y: number,
91
- ): void {
92
- const cells = new Map<number, Connections>()
93
- for (const branch of diagram.branches) {
94
- const span = spans.get(branch.name)
95
- if (!span || span.first > index || (span.last <= index && branch.name !== commit.branch)) continue
96
- const lane = laneByBranch.get(branch.name)!
97
- connect(cells, lane * LANE_WIDTH, { up: index > 0, down: span.last > index }, branchStyle(lane))
98
- }
99
-
100
- const lane = laneByBranch.get(commit.branch)!
101
- const secondParent = commit.parents[1] === undefined ? undefined : commitById.get(commit.parents[1])
102
- if (secondParent) {
103
- const parentLane = laneByBranch.get(secondParent.branch)!
104
- connectHorizontal(cells, lane, parentLane, { sourceUp: true, targetUp: true }, branchStyle(parentLane))
105
- }
106
- paintConnections(grid, cells, y)
107
- grid.setCell(lane * LANE_WIDTH, y, commitGlyph(commit), commitStyle(commit))
108
- }
109
-
110
- function connectHorizontal(
111
- cells: Map<number, Connections>,
112
- sourceLane: number,
113
- targetLane: number,
114
- vertical: { sourceUp?: boolean; sourceDown?: boolean; targetUp?: boolean; targetDown?: boolean },
115
- style: GitGraphCellStyle,
116
- ): void {
117
- if (sourceLane === targetLane) return
118
- const source = sourceLane * LANE_WIDTH
119
- const target = targetLane * LANE_WIDTH
120
- const direction = Math.sign(target - source)
121
- connect(
122
- cells,
123
- source,
124
- { ...verticalAt(vertical.sourceUp, vertical.sourceDown), ...(direction > 0 ? { right: true } : { left: true }) },
125
- style,
126
- )
127
- for (let x = source + direction; x !== target; x += direction) {
128
- connect(cells, x, { left: true, right: true }, style)
129
- }
130
- connect(
131
- cells,
132
- target,
133
- { ...verticalAt(vertical.targetUp, vertical.targetDown), ...(direction > 0 ? { left: true } : { right: true }) },
134
- style,
135
- )
136
- }
137
-
138
- function verticalAt(up: boolean | undefined, down: boolean | undefined): Pick<Connections, "up" | "down"> {
139
- return { ...(up ? { up: true } : {}), ...(down ? { down: true } : {}) }
140
- }
141
-
142
- function connect(
143
- cells: Map<number, Connections>,
144
- x: number,
145
- additions: Omit<Connections, "style">,
146
- style: GitGraphCellStyle,
147
- ): void {
148
- const current = cells.get(x)
149
- cells.set(x, { ...current, ...additions, style: current?.style ?? style })
150
- }
151
-
152
- function paintConnections(grid: GitGraphGrid, cells: Map<number, Connections>, y: number): void {
153
- for (const [x, connections] of cells) grid.setCell(x, y, connectionGlyph(connections), connections.style)
154
- }
155
-
156
- function connectionGlyph({ up, down, left, right }: Connections): string {
157
- const mask = `${up ? 1 : 0}${down ? 1 : 0}${left ? 1 : 0}${right ? 1 : 0}`
158
- const glyphs: Record<string, string> = {
159
- "1100": "│",
160
- "0011": "─",
161
- "0101": "╭",
162
- "0110": "╮",
163
- "1001": "╰",
164
- "1010": "╯",
165
- "1101": "├",
166
- "1110": "┤",
167
- "0111": "┬",
168
- "1011": "┴",
169
- "1111": "┼",
170
- "1000": "│",
171
- "0100": "│",
172
- "0010": "─",
173
- "0001": "─",
174
- }
175
- return glyphs[mask] ?? " "
176
- }
177
-
178
- function branchSpans(diagram: GitGraphDiagram, commitById: Map<string, GitGraphCommit>): Map<string, BranchSpan> {
179
- const spans = new Map<string, BranchSpan>()
180
- diagram.commits.forEach((commit, index) => {
181
- const span = spans.get(commit.branch)
182
- if (span) span.last = index
183
- else spans.set(commit.branch, { first: index, last: index })
184
- for (const parentId of commit.parents) {
185
- const parent = commitById.get(parentId)
186
- if (!parent || parent.branch === commit.branch) continue
187
- const parentSpan = spans.get(parent.branch)
188
- if (parentSpan) parentSpan.last = Math.max(parentSpan.last, index)
189
- }
190
- })
191
- return spans
192
- }
193
-
194
- function branchHeads(diagram: GitGraphDiagram): Map<string, string[]> {
195
- const heads = new Map<string, string[]>()
196
- for (const branch of diagram.branches) {
197
- if (branch.head === undefined) continue
198
- const names = heads.get(branch.head) ?? []
199
- names.push(branch.name)
200
- heads.set(branch.head, names)
201
- }
202
- return heads
203
- }
204
-
205
- function isFork(
206
- commit: GitGraphCommit,
207
- laneByBranch: Map<string, number>,
208
- commitById: Map<string, GitGraphCommit>,
209
- ): boolean {
210
- const parent = commit.parents[0] === undefined ? undefined : commitById.get(commit.parents[0])
211
- return parent !== undefined && laneByBranch.get(parent.branch) !== laneByBranch.get(commit.branch)
212
- }
213
-
214
- function commitGlyph(commit: GitGraphCommit): string {
215
- if (commit.type === "REVERSE") return "⊗"
216
- if (commit.type === "HIGHLIGHT") return "◆"
217
- return commit.parents.length > 1 ? "◎" : "●"
218
- }
219
-
220
- function commitStyle(commit: GitGraphCommit): GitGraphCellStyle {
221
- if (commit.type === "REVERSE") return "reverse"
222
- if (commit.type === "HIGHLIGHT") return "highlight"
223
- return commit.parents.length > 1 ? "merge" : "commit"
224
- }
225
-
226
- function commitLabel(commit: GitGraphCommit, heads: Map<string, string[]>): string {
227
- const subject = commit.message ?? commit.id
228
- const decorations = [...(heads.get(commit.id) ?? []), ...commit.tags].map((value) => `[${value}]`)
229
- return decorations.length === 0 ? subject : `${subject} ${decorations.join(" ")}`
230
- }
231
-
232
- function branchStyle(lane: number): GitGraphCellStyle {
233
- return `branch${lane % 8}` as GitGraphCellStyle
234
- }
1
+ import { DiagramCanvas } from "../core/canvas.js"
2
+ import { diagramTextWidth } from "../core/text.js"
3
+ import type { GitGraphGrid } from "./render-grid.js"
4
+ import type { GitGraphCellStyle, GitGraphCommit, GitGraphDiagram, GitGraphDiagramRenderOptions } from "./types.js"
5
+
6
+ interface BranchSpan {
7
+ first: number
8
+ last: number
9
+ }
10
+
11
+ interface Connections {
12
+ up?: boolean
13
+ down?: boolean
14
+ left?: boolean
15
+ right?: boolean
16
+ style: GitGraphCellStyle
17
+ }
18
+
19
+ const LANE_WIDTH = 2
20
+ const LABEL_GAP = 2
21
+
22
+ export function drawGitGraphDiagramGrid(
23
+ diagram: GitGraphDiagram,
24
+ _options: GitGraphDiagramRenderOptions = {},
25
+ ): GitGraphGrid {
26
+ if (diagram.commits.length === 0) return new DiagramCanvas(0, 0)
27
+ const laneByBranch = new Map(diagram.branches.map((branch, index) => [branch.name, index]))
28
+ const commitById = new Map(diagram.commits.map((commit) => [commit.id, commit]))
29
+ const spans = branchSpans(diagram, commitById)
30
+ const heads = branchHeads(diagram)
31
+ const graphWidth = (diagram.branches.length - 1) * LANE_WIDTH + 1
32
+ let labelWidth = 0
33
+ for (const commit of diagram.commits) labelWidth = Math.max(labelWidth, diagramTextWidth(commitLabel(commit, heads)))
34
+ const forks = diagram.commits.map((commit) => isFork(commit, laneByBranch, commitById))
35
+ const height = diagram.commits.length + forks.filter(Boolean).length
36
+ const grid: GitGraphGrid = new DiagramCanvas(graphWidth + LABEL_GAP + labelWidth, height)
37
+
38
+ let row = 0
39
+ diagram.commits.forEach((commit, index) => {
40
+ if (forks[index]) {
41
+ drawTransitionRow(grid, spans, laneByBranch, commitById, commit, index, row)
42
+ row += 1
43
+ }
44
+ drawCommitRow(grid, diagram, spans, laneByBranch, commitById, commit, index, row)
45
+ grid.setText(graphWidth + LABEL_GAP, row, commitLabel(commit, heads), "label")
46
+ row += 1
47
+ })
48
+ return grid
49
+ }
50
+
51
+ function drawTransitionRow(
52
+ grid: GitGraphGrid,
53
+ spans: Map<string, BranchSpan>,
54
+ laneByBranch: Map<string, number>,
55
+ commitById: Map<string, GitGraphCommit>,
56
+ commit: GitGraphCommit,
57
+ index: number,
58
+ y: number,
59
+ ): void {
60
+ const cells = new Map<number, Connections>()
61
+ for (const [branch, span] of spans) {
62
+ if (span.first >= index || span.last < index) continue
63
+ const lane = laneByBranch.get(branch)!
64
+ connect(cells, lane * LANE_WIDTH, { up: true, down: true }, branchStyle(lane))
65
+ }
66
+
67
+ const lane = laneByBranch.get(commit.branch)!
68
+ const firstParent = commit.parents[0] === undefined ? undefined : commitById.get(commit.parents[0])
69
+ if (firstParent && firstParent.branch !== commit.branch) {
70
+ const parentLane = laneByBranch.get(firstParent.branch)!
71
+ connectHorizontal(
72
+ cells,
73
+ parentLane,
74
+ lane,
75
+ { sourceUp: true, sourceDown: true, targetDown: true },
76
+ branchStyle(lane),
77
+ )
78
+ }
79
+ paintConnections(grid, cells, y)
80
+ }
81
+
82
+ function drawCommitRow(
83
+ grid: GitGraphGrid,
84
+ diagram: GitGraphDiagram,
85
+ spans: Map<string, BranchSpan>,
86
+ laneByBranch: Map<string, number>,
87
+ commitById: Map<string, GitGraphCommit>,
88
+ commit: GitGraphCommit,
89
+ index: number,
90
+ y: number,
91
+ ): void {
92
+ const cells = new Map<number, Connections>()
93
+ for (const branch of diagram.branches) {
94
+ const span = spans.get(branch.name)
95
+ if (!span || span.first > index || (span.last <= index && branch.name !== commit.branch)) continue
96
+ const lane = laneByBranch.get(branch.name)!
97
+ connect(cells, lane * LANE_WIDTH, { up: index > 0, down: span.last > index }, branchStyle(lane))
98
+ }
99
+
100
+ const lane = laneByBranch.get(commit.branch)!
101
+ const secondParent = commit.parents[1] === undefined ? undefined : commitById.get(commit.parents[1])
102
+ if (secondParent) {
103
+ const parentLane = laneByBranch.get(secondParent.branch)!
104
+ connectHorizontal(cells, lane, parentLane, { sourceUp: true, targetUp: true }, branchStyle(parentLane))
105
+ }
106
+ paintConnections(grid, cells, y)
107
+ grid.setCell(lane * LANE_WIDTH, y, commitGlyph(commit), commitStyle(commit))
108
+ }
109
+
110
+ function connectHorizontal(
111
+ cells: Map<number, Connections>,
112
+ sourceLane: number,
113
+ targetLane: number,
114
+ vertical: { sourceUp?: boolean; sourceDown?: boolean; targetUp?: boolean; targetDown?: boolean },
115
+ style: GitGraphCellStyle,
116
+ ): void {
117
+ if (sourceLane === targetLane) return
118
+ const source = sourceLane * LANE_WIDTH
119
+ const target = targetLane * LANE_WIDTH
120
+ const direction = Math.sign(target - source)
121
+ connect(
122
+ cells,
123
+ source,
124
+ { ...verticalAt(vertical.sourceUp, vertical.sourceDown), ...(direction > 0 ? { right: true } : { left: true }) },
125
+ style,
126
+ )
127
+ for (let x = source + direction; x !== target; x += direction) {
128
+ connect(cells, x, { left: true, right: true }, style)
129
+ }
130
+ connect(
131
+ cells,
132
+ target,
133
+ { ...verticalAt(vertical.targetUp, vertical.targetDown), ...(direction > 0 ? { left: true } : { right: true }) },
134
+ style,
135
+ )
136
+ }
137
+
138
+ function verticalAt(up: boolean | undefined, down: boolean | undefined): Pick<Connections, "up" | "down"> {
139
+ return { ...(up ? { up: true } : {}), ...(down ? { down: true } : {}) }
140
+ }
141
+
142
+ function connect(
143
+ cells: Map<number, Connections>,
144
+ x: number,
145
+ additions: Omit<Connections, "style">,
146
+ style: GitGraphCellStyle,
147
+ ): void {
148
+ const current = cells.get(x)
149
+ cells.set(x, { ...current, ...additions, style: current?.style ?? style })
150
+ }
151
+
152
+ function paintConnections(grid: GitGraphGrid, cells: Map<number, Connections>, y: number): void {
153
+ for (const [x, connections] of cells) grid.setCell(x, y, connectionGlyph(connections), connections.style)
154
+ }
155
+
156
+ function connectionGlyph({ up, down, left, right }: Connections): string {
157
+ const mask = `${up ? 1 : 0}${down ? 1 : 0}${left ? 1 : 0}${right ? 1 : 0}`
158
+ const glyphs: Record<string, string> = {
159
+ "1100": "│",
160
+ "0011": "─",
161
+ "0101": "╭",
162
+ "0110": "╮",
163
+ "1001": "╰",
164
+ "1010": "╯",
165
+ "1101": "├",
166
+ "1110": "┤",
167
+ "0111": "┬",
168
+ "1011": "┴",
169
+ "1111": "┼",
170
+ "1000": "│",
171
+ "0100": "│",
172
+ "0010": "─",
173
+ "0001": "─",
174
+ }
175
+ return glyphs[mask] ?? " "
176
+ }
177
+
178
+ function branchSpans(diagram: GitGraphDiagram, commitById: Map<string, GitGraphCommit>): Map<string, BranchSpan> {
179
+ const spans = new Map<string, BranchSpan>()
180
+ diagram.commits.forEach((commit, index) => {
181
+ const span = spans.get(commit.branch)
182
+ if (span) span.last = index
183
+ else spans.set(commit.branch, { first: index, last: index })
184
+ for (const parentId of commit.parents) {
185
+ const parent = commitById.get(parentId)
186
+ if (!parent || parent.branch === commit.branch) continue
187
+ const parentSpan = spans.get(parent.branch)
188
+ if (parentSpan) parentSpan.last = Math.max(parentSpan.last, index)
189
+ }
190
+ })
191
+ return spans
192
+ }
193
+
194
+ function branchHeads(diagram: GitGraphDiagram): Map<string, string[]> {
195
+ const heads = new Map<string, string[]>()
196
+ for (const branch of diagram.branches) {
197
+ if (branch.head === undefined) continue
198
+ const names = heads.get(branch.head) ?? []
199
+ names.push(branch.name)
200
+ heads.set(branch.head, names)
201
+ }
202
+ return heads
203
+ }
204
+
205
+ function isFork(
206
+ commit: GitGraphCommit,
207
+ laneByBranch: Map<string, number>,
208
+ commitById: Map<string, GitGraphCommit>,
209
+ ): boolean {
210
+ const parent = commit.parents[0] === undefined ? undefined : commitById.get(commit.parents[0])
211
+ return parent !== undefined && laneByBranch.get(parent.branch) !== laneByBranch.get(commit.branch)
212
+ }
213
+
214
+ function commitGlyph(commit: GitGraphCommit): string {
215
+ if (commit.type === "REVERSE") return "⊗"
216
+ if (commit.type === "HIGHLIGHT") return "◆"
217
+ return commit.parents.length > 1 ? "◎" : "●"
218
+ }
219
+
220
+ function commitStyle(commit: GitGraphCommit): GitGraphCellStyle {
221
+ if (commit.type === "REVERSE") return "reverse"
222
+ if (commit.type === "HIGHLIGHT") return "highlight"
223
+ return commit.parents.length > 1 ? "merge" : "commit"
224
+ }
225
+
226
+ function commitLabel(commit: GitGraphCommit, heads: Map<string, string[]>): string {
227
+ const subject = commit.message ?? commit.id
228
+ const decorations = [...(heads.get(commit.id) ?? []), ...commit.tags].map((value) => `[${value}]`)
229
+ return decorations.length === 0 ? subject : `${subject} ${decorations.join(" ")}`
230
+ }
231
+
232
+ function branchStyle(lane: number): GitGraphCellStyle {
233
+ return `branch${lane % 8}` as GitGraphCellStyle
234
+ }