@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.
- package/package.json +2 -2
- package/script/layout-audit.ts +98 -98
- package/src/core/canvas.ts +228 -228
- package/src/core/color/style.ts +56 -56
- package/src/core/drawing.ts +301 -301
- package/src/core/geometry.ts +347 -347
- package/src/core/mermaid.ts +38 -38
- package/src/core/render-grid.ts +51 -51
- package/src/core/spatial.ts +243 -243
- package/src/core/text-lines.ts +32 -32
- package/src/core/text.ts +44 -44
- package/src/detect.ts +17 -17
- package/src/diagnostics.ts +16 -16
- package/src/flowchart/drawing.ts +340 -340
- package/src/flowchart/labels.ts +144 -144
- package/src/flowchart/layout.ts +1427 -1427
- package/src/flowchart/options.ts +12 -12
- package/src/flowchart/parser.ts +467 -467
- package/src/flowchart/render.ts +10 -10
- package/src/flowchart/routing.ts +1542 -1542
- package/src/flowchart/style.ts +79 -79
- package/src/flowchart/types.ts +65 -65
- package/src/gantt/diagram.ts +8 -8
- package/src/gantt/drawing.ts +191 -191
- package/src/gantt/parser.ts +161 -161
- package/src/gantt/render-grid.ts +17 -17
- package/src/gantt/style.ts +36 -36
- package/src/gantt/types.ts +44 -44
- package/src/gitgraph/diagram.ts +8 -8
- package/src/gitgraph/drawing.ts +234 -234
- package/src/gitgraph/parser.ts +219 -219
- package/src/gitgraph/render-grid.ts +17 -17
- package/src/gitgraph/style.ts +37 -37
- package/src/gitgraph/types.ts +36 -36
- package/src/markdown.ts +336 -336
- package/src/palette.ts +75 -75
- package/src/plugin.ts +15 -15
- package/src/sequence/diagram.ts +8 -8
- package/src/sequence/drawing.ts +287 -287
- package/src/sequence/options.ts +8 -8
- package/src/sequence/parser.ts +282 -282
- package/src/sequence/placement.ts +684 -684
- package/src/sequence/render-grid.ts +22 -22
- package/src/sequence/style.ts +81 -81
- package/src/sequence/types.ts +74 -74
- package/src/state/diagram.ts +8 -8
- package/src/state/drawing.ts +360 -360
- package/src/state/endpoint.ts +15 -15
- package/src/state/layout.ts +1134 -1134
- package/src/state/note.ts +59 -59
- package/src/state/options.ts +11 -11
- package/src/state/parser.ts +224 -224
- package/src/state/render-grid.ts +22 -22
- package/src/state/routing.ts +1522 -1522
- package/src/state/search.ts +103 -103
- package/src/state/style.ts +52 -52
- package/src/state/types.ts +63 -63
- package/src/state/visible-model.ts +77 -77
- package/src/test/diagram.ts +32 -32
- package/src/test/layout-audit/fixtures.ts +538 -538
- package/src/test/layout-audit/harness.ts +522 -522
- package/src/timeline/diagram.ts +8 -8
- package/src/timeline/drawing.ts +109 -109
- package/src/timeline/parser.ts +119 -119
- package/src/timeline/render-grid.ts +17 -17
- package/src/timeline/style.ts +36 -36
- package/src/timeline/types.ts +31 -31
- package/tsconfig.json +10 -10
- package/src/core/canvas.test.ts +0 -203
- package/src/core/color/style.test.ts +0 -24
- package/src/core/drawing.test.ts +0 -116
- package/src/core/geometry.test.ts +0 -112
- package/src/core/spatial.test.ts +0 -87
- package/src/core/text.test.ts +0 -33
- package/src/flowchart/flowchart.test.ts +0 -2800
- package/src/flowchart/labels.test.ts +0 -127
- package/src/flowchart/routing.test.ts +0 -368
- package/src/gantt/diagram.test.ts +0 -124
- package/src/gitgraph/diagram.test.ts +0 -183
- package/src/layout-audit.test.ts +0 -92
- package/src/palette.test.ts +0 -103
- package/src/sequence/diagram.test.ts +0 -757
- package/src/sequence/placement.test.ts +0 -219
- package/src/state/diagram.test.ts +0 -1386
- package/src/state/layout.test.ts +0 -314
- package/src/state/routing.test.ts +0 -693
- package/src/state/style.test.ts +0 -113
- package/src/state/visible-model.test.ts +0 -84
- package/src/test/diagnostics.test.ts +0 -129
- package/src/test/markdown.test.ts +0 -474
- package/src/timeline/diagram.test.ts +0 -188
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { MermaidSyntaxError } from "../diagnostics.js"
|
|
3
|
-
import { renderGitGraphDiagram } from "./diagram.js"
|
|
4
|
-
import { drawGitGraphDiagramGrid } from "./drawing.js"
|
|
5
|
-
import { isMermaidGitGraphDiagram, parseMermaidGitGraphDiagram } from "./parser.js"
|
|
6
|
-
import { renderGitGraphGridText } from "./render-grid.js"
|
|
7
|
-
import { resolveGitGraphStyleColors } from "./style.js"
|
|
8
|
-
|
|
9
|
-
describe("GitGraphDiagram", () => {
|
|
10
|
-
test("detects and parses commits, branches, checkout, tags, types, and merges", () => {
|
|
11
|
-
const diagram = parseMermaidGitGraphDiagram(`gitGraph TB:
|
|
12
|
-
commit id: "init"
|
|
13
|
-
branch feature order: 1
|
|
14
|
-
commit id: "api" msg: "Add API" tag: "ready"
|
|
15
|
-
checkout main
|
|
16
|
-
commit id: "docs" type: HIGHLIGHT
|
|
17
|
-
merge feature id: "merge-feature"`)
|
|
18
|
-
|
|
19
|
-
expect(diagram).toEqual({
|
|
20
|
-
direction: "TB",
|
|
21
|
-
branches: [
|
|
22
|
-
{ name: "main", order: 0, head: "merge-feature" },
|
|
23
|
-
{ name: "feature", order: 1, head: "api" },
|
|
24
|
-
],
|
|
25
|
-
commits: [
|
|
26
|
-
{ id: "init", tags: [], type: "NORMAL", branch: "main", parents: [] },
|
|
27
|
-
{ id: "api", message: "Add API", tags: ["ready"], type: "NORMAL", branch: "feature", parents: ["init"] },
|
|
28
|
-
{ id: "docs", tags: [], type: "HIGHLIGHT", branch: "main", parents: ["init"] },
|
|
29
|
-
{
|
|
30
|
-
id: "merge-feature",
|
|
31
|
-
tags: [],
|
|
32
|
-
type: "NORMAL",
|
|
33
|
-
branch: "main",
|
|
34
|
-
parents: ["docs", "api"],
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test("renders branch and merge transitions beside compact labels", () => {
|
|
41
|
-
const source = `gitGraph
|
|
42
|
-
commit id: "baseline"
|
|
43
|
-
branch refactor
|
|
44
|
-
commit id: "extract-seam" msg: "Extract seam"
|
|
45
|
-
commit id: "add-tests" tag: "ready"
|
|
46
|
-
checkout main
|
|
47
|
-
commit id: "unrelated-fix"
|
|
48
|
-
merge refactor id: "land-refactor" tag: "v2"`
|
|
49
|
-
|
|
50
|
-
expect(renderGitGraphDiagram(source)).toBe(`● baseline
|
|
51
|
-
├─╮
|
|
52
|
-
│ ● Extract seam
|
|
53
|
-
│ ● add-tests [refactor] [ready]
|
|
54
|
-
● │ unrelated-fix
|
|
55
|
-
◎─╯ land-refactor [main] [v2]`)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test("uses deterministic generated ids", () => {
|
|
59
|
-
expect(parseMermaidGitGraphDiagram("gitGraph\n commit\n commit").commits.map((commit) => commit.id)).toEqual([
|
|
60
|
-
"commit-1",
|
|
61
|
-
"commit-2",
|
|
62
|
-
])
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test("supports shorthand messages and preserves branch heads without direct commits", () => {
|
|
66
|
-
const diagram = parseMermaidGitGraphDiagram(`gitGraph
|
|
67
|
-
commit "Initial release"
|
|
68
|
-
branch feature
|
|
69
|
-
checkout main
|
|
70
|
-
commit id: next`)
|
|
71
|
-
|
|
72
|
-
expect(diagram.commits[0]?.message).toBe("Initial release")
|
|
73
|
-
expect(diagram.branches).toEqual([
|
|
74
|
-
{ name: "main", order: 0, head: "next" },
|
|
75
|
-
{ name: "feature", head: "commit-1" },
|
|
76
|
-
])
|
|
77
|
-
expect(
|
|
78
|
-
renderGitGraphDiagram(`gitGraph
|
|
79
|
-
commit id: base
|
|
80
|
-
branch feature
|
|
81
|
-
checkout main
|
|
82
|
-
commit id: next`),
|
|
83
|
-
).toContain("base [feature]")
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
test("places unordered branches before explicitly ordered branches", () => {
|
|
87
|
-
const diagram = parseMermaidGitGraphDiagram(`gitGraph
|
|
88
|
-
commit id: base
|
|
89
|
-
branch later order: 2
|
|
90
|
-
checkout main
|
|
91
|
-
branch ordinary
|
|
92
|
-
checkout main
|
|
93
|
-
branch earlier order: 1`)
|
|
94
|
-
|
|
95
|
-
expect(diagram.branches.map((branch) => branch.name)).toEqual(["main", "ordinary", "earlier", "later"])
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test("keeps comment markers inside quoted labels", () => {
|
|
99
|
-
expect(parseMermaidGitGraphDiagram('gitGraph\n commit id: "release%%candidate" %% comment').commits[0]?.id).toBe(
|
|
100
|
-
"release%%candidate",
|
|
101
|
-
)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test("uses rounded routing for wide lane transitions", () => {
|
|
105
|
-
expect(
|
|
106
|
-
renderGitGraphDiagram(`gitGraph
|
|
107
|
-
commit id: base
|
|
108
|
-
branch one
|
|
109
|
-
branch two
|
|
110
|
-
commit id: work`),
|
|
111
|
-
).toBe(`● base [main] [one]
|
|
112
|
-
├───╮
|
|
113
|
-
● work [two]`)
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test("preserves direction semantics while rendering vertically", () => {
|
|
117
|
-
const source = "gitGraph BT:\n commit id: one"
|
|
118
|
-
const diagram = parseMermaidGitGraphDiagram(source)
|
|
119
|
-
expect(diagram.direction).toBe("BT")
|
|
120
|
-
expect(renderGitGraphGridText(drawGitGraphDiagramGrid(diagram, { direction: "LR" }))).toBe(
|
|
121
|
-
renderGitGraphDiagram(source),
|
|
122
|
-
)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
test("reports semantic failures with source diagnostics", () => {
|
|
126
|
-
expect(() => parseMermaidGitGraphDiagram("gitGraph\n checkout missing")).toThrow(
|
|
127
|
-
new MermaidSyntaxError("gitGraph", 2, "checkout missing", 'Unknown branch "missing"'),
|
|
128
|
-
)
|
|
129
|
-
expect(() => parseMermaidGitGraphDiagram("gitGraph\n cherry-pick id: one")).toThrow(
|
|
130
|
-
new MermaidSyntaxError("gitGraph", 2, "cherry-pick id: one", "Cherry-pick is not supported"),
|
|
131
|
-
)
|
|
132
|
-
expect(() => parseMermaidGitGraphDiagram("gitGraph\n commit id: same\n commit id: same")).toThrow(
|
|
133
|
-
'Duplicate commit id "same"',
|
|
134
|
-
)
|
|
135
|
-
expect(() => parseMermaidGitGraphDiagram("gitGraph\n branch feature\n checkout main\n branch feature")).toThrow(
|
|
136
|
-
'Duplicate branch "feature"',
|
|
137
|
-
)
|
|
138
|
-
expect(() =>
|
|
139
|
-
parseMermaidGitGraphDiagram("gitGraph\n branch feature\n commit id: work\n checkout main\n merge feature"),
|
|
140
|
-
).toThrow('Branch "main" has no commits')
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
test("draws semantic styles for rails, commit types, merges, and labels", () => {
|
|
144
|
-
const grid = drawGitGraphDiagramGrid(
|
|
145
|
-
parseMermaidGitGraphDiagram(`gitGraph
|
|
146
|
-
commit id: base
|
|
147
|
-
branch feature
|
|
148
|
-
commit id: work type: REVERSE
|
|
149
|
-
checkout main
|
|
150
|
-
commit id: checkpoint type: HIGHLIGHT
|
|
151
|
-
merge feature id: done`),
|
|
152
|
-
)
|
|
153
|
-
const styles = new Set(grid.rows.flatMap((row) => row.map((cell) => cell.style).filter(Boolean)))
|
|
154
|
-
|
|
155
|
-
expect(styles).toEqual(new Set(["branch0", "branch1", "commit", "reverse", "highlight", "merge", "label"]))
|
|
156
|
-
expect(Object.keys(resolveGitGraphStyleColors()).sort()).toEqual(
|
|
157
|
-
[
|
|
158
|
-
"branch0",
|
|
159
|
-
"branch1",
|
|
160
|
-
"branch2",
|
|
161
|
-
"branch3",
|
|
162
|
-
"branch4",
|
|
163
|
-
"branch5",
|
|
164
|
-
"branch6",
|
|
165
|
-
"branch7",
|
|
166
|
-
"commit",
|
|
167
|
-
"highlight",
|
|
168
|
-
"label",
|
|
169
|
-
"merge",
|
|
170
|
-
"reverse",
|
|
171
|
-
].sort(),
|
|
172
|
-
)
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
test("recognizes only GitGraph headers", () => {
|
|
176
|
-
expect(isMermaidGitGraphDiagram("%% comment\ngitGraph LR:\n commit")).toBe(true)
|
|
177
|
-
expect(isMermaidGitGraphDiagram("graph LR\n A --> B")).toBe(false)
|
|
178
|
-
expect(() => parseMermaidGitGraphDiagram("commit id: missing-header")).toThrow("GitGraph header is required")
|
|
179
|
-
expect(() => parseMermaidGitGraphDiagram("gitGraph\n commit\n gitGraph")).toThrow(
|
|
180
|
-
"GitGraph header can only appear once",
|
|
181
|
-
)
|
|
182
|
-
})
|
|
183
|
-
})
|
package/src/layout-audit.test.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import { auditAllFixtures, auditFixture, summarizeAudits, worstAudits } from "./test/layout-audit/harness.js"
|
|
3
|
-
import { layoutFixtures } from "./test/layout-audit/fixtures.js"
|
|
4
|
-
|
|
5
|
-
test("audits deterministic flowchart and state layout families", () => {
|
|
6
|
-
const fixtures = layoutFixtures()
|
|
7
|
-
const flowcharts = fixtures.filter((fixture) => fixture.kind === "flowchart")
|
|
8
|
-
const states = fixtures.filter((fixture) => fixture.kind === "state")
|
|
9
|
-
expect(flowcharts.length).toBeGreaterThanOrEqual(100)
|
|
10
|
-
expect(states.length).toBeGreaterThanOrEqual(100)
|
|
11
|
-
expect(new Set(fixtures.map((fixture) => fixture.id)).size).toBe(fixtures.length)
|
|
12
|
-
|
|
13
|
-
const startedAt = performance.now()
|
|
14
|
-
const audits = auditAllFixtures()
|
|
15
|
-
const elapsedMs = performance.now() - startedAt
|
|
16
|
-
const violations = audits.flatMap((audit) =>
|
|
17
|
-
audit.violations.map((violation) => `${audit.fixture.id} @${audit.viewport}: ${violation}`),
|
|
18
|
-
)
|
|
19
|
-
const summary = summarizeAudits(audits)
|
|
20
|
-
|
|
21
|
-
expect(audits.length).toBeGreaterThanOrEqual(fixtures.length)
|
|
22
|
-
expect(violations).toEqual([])
|
|
23
|
-
for (const audit of audits.filter((audit) => audit.fixture.kind === "state")) {
|
|
24
|
-
expect(audit.viewport).toBe(audit.fixture.profile === "short" ? 60 : audit.fixture.profile === "unicode" ? 80 : 120)
|
|
25
|
-
}
|
|
26
|
-
for (const id of ["state/chain/lr-long", "state/chain/rl-long"]) {
|
|
27
|
-
const audit = audits.find((candidate) => candidate.fixture.id === id)!
|
|
28
|
-
expect(audit.viewport).toBe(120)
|
|
29
|
-
expect([audit.metrics.width, audit.metrics.height, audit.metrics.overflow]).toEqual([84, 41, 0])
|
|
30
|
-
}
|
|
31
|
-
expect(
|
|
32
|
-
audits
|
|
33
|
-
.filter((audit) => audit.fixture.id === "flowchart/deployment-architecture/curated")
|
|
34
|
-
.map((audit) => audit.viewport),
|
|
35
|
-
).toEqual([60, 80, 120])
|
|
36
|
-
// decision-loops is a deliberately crossing-heavy family; ceiling it separately so it cannot absorb the
|
|
37
|
-
// p95 headroom of the established families.
|
|
38
|
-
const established = summarizeAudits(audits.filter((audit) => audit.fixture.family !== "decision-loops")).total
|
|
39
|
-
expect(established.area.max).toBeLessThanOrEqual(11_011)
|
|
40
|
-
expect(established.area.p95).toBeLessThanOrEqual(5_313)
|
|
41
|
-
expect(established.bends.max).toBeLessThanOrEqual(30)
|
|
42
|
-
expect(established.bends.p95).toBeLessThanOrEqual(11)
|
|
43
|
-
expect(established.crossings.total).toBeLessThanOrEqual(40)
|
|
44
|
-
expect(established.crossings.max).toBeLessThanOrEqual(3)
|
|
45
|
-
expect(established.routeLength.max).toBeLessThanOrEqual(930)
|
|
46
|
-
expect(established.routeLength.p95).toBeLessThanOrEqual(364)
|
|
47
|
-
expect(established.sharedRouteCells.max).toBeLessThanOrEqual(547)
|
|
48
|
-
expect(established.sharedRouteCells.p95).toBeLessThanOrEqual(122)
|
|
49
|
-
expect(established.overflow.max).toBeLessThanOrEqual(170)
|
|
50
|
-
expect(established.overflow.p95).toBeLessThanOrEqual(99)
|
|
51
|
-
const decisionLoops = summarizeAudits(audits.filter((audit) => audit.fixture.family === "decision-loops")).total
|
|
52
|
-
expect(decisionLoops.runs).toBeGreaterThan(0)
|
|
53
|
-
expect(decisionLoops.area.max).toBeLessThanOrEqual(8_784)
|
|
54
|
-
expect(decisionLoops.bends.max).toBeLessThanOrEqual(24)
|
|
55
|
-
expect(decisionLoops.crossings.total).toBeLessThanOrEqual(24)
|
|
56
|
-
expect(decisionLoops.crossings.max).toBeLessThanOrEqual(8)
|
|
57
|
-
expect(decisionLoops.routeLength.max).toBeLessThanOrEqual(526)
|
|
58
|
-
expect(decisionLoops.sharedRouteCells.max).toBeLessThanOrEqual(352)
|
|
59
|
-
expect(decisionLoops.overflow.max).toBeLessThanOrEqual(84)
|
|
60
|
-
expect(summary.state.crossings.total).toBe(0)
|
|
61
|
-
|
|
62
|
-
for (const fixture of [...Map.groupBy(fixtures, (candidate) => `${candidate.kind}/${candidate.family}`).values()].map(
|
|
63
|
-
(family) => family[0]!,
|
|
64
|
-
)) {
|
|
65
|
-
const first = auditFixture(fixture, 80)
|
|
66
|
-
const second = auditFixture(fixture, 80)
|
|
67
|
-
expect(second.output).toBe(first.output)
|
|
68
|
-
expect(second.metrics).toEqual(first.metrics)
|
|
69
|
-
expect(second.violations).toEqual(first.violations)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
73
|
-
`[layout-audit] ${fixtures.length} sources, ${audits.length} runs, ${elapsedMs.toFixed(0)}ms`,
|
|
74
|
-
JSON.stringify({
|
|
75
|
-
summary,
|
|
76
|
-
worst: {
|
|
77
|
-
area: worstAudits(audits, "area", 3).map((audit) => [audit.fixture.id, audit.viewport, audit.metrics.area]),
|
|
78
|
-
bends: worstAudits(audits, "bends", 3).map((audit) => [audit.fixture.id, audit.viewport, audit.metrics.bends]),
|
|
79
|
-
crossings: worstAudits(audits, "crossings", 3).map((audit) => [
|
|
80
|
-
audit.fixture.id,
|
|
81
|
-
audit.viewport,
|
|
82
|
-
audit.metrics.crossings,
|
|
83
|
-
]),
|
|
84
|
-
overflow: worstAudits(audits, "overflow", 3).map((audit) => [
|
|
85
|
-
audit.fixture.id,
|
|
86
|
-
audit.viewport,
|
|
87
|
-
audit.metrics.overflow,
|
|
88
|
-
]),
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
)
|
|
92
|
-
}, 40_000)
|
package/src/palette.test.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { RGBA } from "@opentui/core"
|
|
3
|
-
import { blendColor } from "./core/color/style.js"
|
|
4
|
-
import { createOpenCodeDiagramPalette, resolveOpenCodeDiagramPalette } from "./palette.js"
|
|
5
|
-
|
|
6
|
-
type Rgb = readonly [number, number, number]
|
|
7
|
-
|
|
8
|
-
const rgb = (value: Rgb) => RGBA.fromInts(...value)
|
|
9
|
-
|
|
10
|
-
describe("OpenCode diagram palette", () => {
|
|
11
|
-
test.each([
|
|
12
|
-
{
|
|
13
|
-
name: "dark theme",
|
|
14
|
-
text: [230, 232, 240],
|
|
15
|
-
subdued: [114, 120, 138],
|
|
16
|
-
secondary: [172, 176, 189],
|
|
17
|
-
muted: [149, 154, 169],
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "light theme",
|
|
21
|
-
text: [32, 35, 43],
|
|
22
|
-
subdued: [119, 125, 138],
|
|
23
|
-
secondary: [76, 80, 91],
|
|
24
|
-
muted: [93, 98, 110],
|
|
25
|
-
},
|
|
26
|
-
] satisfies ReadonlyArray<{
|
|
27
|
-
name: string
|
|
28
|
-
text: Rgb
|
|
29
|
-
subdued: Rgb
|
|
30
|
-
secondary: Rgb
|
|
31
|
-
muted: Rgb
|
|
32
|
-
}>)("derives a controlled neutral ladder for a $name", ({ text, subdued, secondary, muted }) => {
|
|
33
|
-
const primary = rgb(text)
|
|
34
|
-
const info = RGBA.fromInts(40, 120, 220)
|
|
35
|
-
const success = RGBA.fromInts(80, 180, 120)
|
|
36
|
-
const warning = RGBA.fromInts(220, 160, 80)
|
|
37
|
-
const background = RGBA.fromInts(10, 20, 30)
|
|
38
|
-
const accent = {
|
|
39
|
-
soft: RGBA.fromInts(180, 100, 40),
|
|
40
|
-
clear: RGBA.fromInts(240, 160, 80),
|
|
41
|
-
}
|
|
42
|
-
const palette = createOpenCodeDiagramPalette({
|
|
43
|
-
text: primary,
|
|
44
|
-
subdued: rgb(subdued),
|
|
45
|
-
info,
|
|
46
|
-
success,
|
|
47
|
-
warning,
|
|
48
|
-
background,
|
|
49
|
-
accent,
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
expect(palette.text).toBe(primary)
|
|
53
|
-
expect(palette.primary).toBe(primary)
|
|
54
|
-
expect(palette.secondary.equals(rgb(secondary))).toBe(true)
|
|
55
|
-
expect(palette.muted.equals(rgb(muted))).toBe(true)
|
|
56
|
-
expect(palette.warning).toBe(info)
|
|
57
|
-
expect(palette.background).toBe(background)
|
|
58
|
-
expect(palette.request).toBe(success)
|
|
59
|
-
expect(palette.response).toBe(warning)
|
|
60
|
-
expect(palette.note).toBe(primary)
|
|
61
|
-
expect(palette.noteBackground.equals(blendColor(background, rgb(subdued), 0.25))).toBe(true)
|
|
62
|
-
expect(palette.boxText).toBe(primary)
|
|
63
|
-
expect(palette.boxBorder.equals(rgb(muted))).toBe(true)
|
|
64
|
-
expect(palette.line.equals(rgb(subdued))).toBe(true)
|
|
65
|
-
expect(palette.labelBackground.toInts()[3]).toBe(20)
|
|
66
|
-
expect(palette.group).toBe(accent.soft)
|
|
67
|
-
expect(palette.groupText).toBe(accent.soft)
|
|
68
|
-
expect(palette.marker.equals(rgb(secondary))).toBe(true)
|
|
69
|
-
expect(palette.noteBorder).toBe(accent.soft)
|
|
70
|
-
expect(palette.noteText).toBe(accent.clear)
|
|
71
|
-
expect(palette.noteConnector).toBe(accent.soft)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test.each([
|
|
75
|
-
{ mode: "dark", soft: 300, clear: 200 },
|
|
76
|
-
{ mode: "light", soft: 700, clear: 800 },
|
|
77
|
-
] as const)("uses the selected $mode mode even with a literal background", ({ mode, soft, clear }) => {
|
|
78
|
-
const accent = {
|
|
79
|
-
200: rgb([200, 100, 100]),
|
|
80
|
-
300: rgb([180, 90, 90]),
|
|
81
|
-
700: rgb([120, 60, 60]),
|
|
82
|
-
800: rgb([100, 50, 50]),
|
|
83
|
-
}
|
|
84
|
-
const theme = {
|
|
85
|
-
text: {
|
|
86
|
-
base: rgb([230, 232, 240]),
|
|
87
|
-
muted: rgb([114, 120, 138]),
|
|
88
|
-
feedback: {
|
|
89
|
-
info: { base: rgb([40, 120, 220]) },
|
|
90
|
-
success: { base: rgb([80, 180, 120]) },
|
|
91
|
-
warning: { base: rgb([220, 160, 80]) },
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
background: { base: rgb([250, 250, 250]) },
|
|
95
|
-
categorical: [accent],
|
|
96
|
-
}
|
|
97
|
-
const palette = resolveOpenCodeDiagramPalette(theme, mode)
|
|
98
|
-
|
|
99
|
-
expect(palette.group).toBe(accent[soft])
|
|
100
|
-
expect(palette.noteBorder).toBe(accent[soft])
|
|
101
|
-
expect(palette.noteText).toBe(accent[clear])
|
|
102
|
-
})
|
|
103
|
-
})
|