@zombie-mermaid/mermaid-parser 2.2.1 → 3.0.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.
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@zombie-mermaid/mermaid-parser",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "description": "Parsers for class, ER, sequence, and XY chart diagrams — the per-type parse functions both svg-renderer and ascii-renderer import directly.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/dfadler/zombie-mermaid",
9
+ "directory": "packages/mermaid-parser"
10
+ },
6
11
  "type": "module",
7
12
  "sideEffects": false,
8
13
  "main": "dist/index.cjs",
@@ -30,6 +35,6 @@
30
35
  "LICENSE"
31
36
  ],
32
37
  "dependencies": {
33
- "@zombie-mermaid/core": "workspace:*"
38
+ "@zombie-mermaid/core": "3.0.0"
34
39
  }
35
- }
40
+ }
@@ -7,7 +7,6 @@ import {
7
7
  CHART_ACCENT_FALLBACK,
8
8
  isValidHex,
9
9
  isDarkBackground,
10
- mixHexColors,
11
10
  getSeriesColor,
12
11
  } from '@zombie-mermaid/mermaid-parser'
13
12
 
@@ -43,24 +42,6 @@ describe('isDarkBackground', () => {
43
42
  })
44
43
  })
45
44
 
46
- describe('mixHexColors', () => {
47
- it('returns the background color unchanged at ratio 0', () => {
48
- expect(mixHexColors('#000000', '#ffffff', 0)).toBe('#000000')
49
- })
50
-
51
- it('returns the foreground color unchanged at ratio 1', () => {
52
- expect(mixHexColors('#000000', '#ffffff', 1)).toBe('#ffffff')
53
- })
54
-
55
- it('blends bg and fg proportionally at ratio 0.5', () => {
56
- expect(mixHexColors('#000000', '#ffffff', 0.5)).toBe('#808080')
57
- })
58
-
59
- it('blends non-grayscale colors channel by channel', () => {
60
- expect(mixHexColors('#3b82f6', '#3b82f6', 0.5)).toBe('#3b82f6')
61
- })
62
- })
63
-
64
45
  describe('getSeriesColor', () => {
65
46
  it('returns the accent color unchanged for index 0', () => {
66
47
  expect(getSeriesColor(0, '#3b82f6')).toBe('#3b82f6')
@@ -81,27 +81,6 @@ function hslToHex(h: number, s: number, l: number): string {
81
81
  return `#${toHex(r)}${toHex(g)}${toHex(b)}`
82
82
  }
83
83
 
84
- // ---------------------------------------------------------------------------
85
- // Hex ↔ RGB conversion
86
- // ---------------------------------------------------------------------------
87
-
88
- function hexToRgb(hex: string): [number, number, number] {
89
- const h = hex.replace('#', '')
90
- return [
91
- parseInt(h.substring(0, 2), 16),
92
- parseInt(h.substring(2, 4), 16),
93
- parseInt(h.substring(4, 6), 16),
94
- ]
95
- }
96
-
97
- function rgbToHex(r: number, g: number, b: number): string {
98
- const toHex = (v: number) =>
99
- Math.round(Math.max(0, Math.min(255, v)))
100
- .toString(16)
101
- .padStart(2, '0')
102
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`
103
- }
104
-
105
84
  // ---------------------------------------------------------------------------
106
85
  // Public API
107
86
  // ---------------------------------------------------------------------------
@@ -118,26 +97,6 @@ export function isDarkBackground(bgHex: string): boolean {
118
97
  return hexToHsl(bgHex)[2] < 50
119
98
  }
120
99
 
121
- /**
122
- * Mix two hex colors in RGB space.
123
- * `ratio` controls how much of `fgHex` shows: 0 = pure bg, 1 = pure fg.
124
- * Equivalent to alpha-compositing fg over bg at the given opacity.
125
- */
126
- export function mixHexColors(
127
- bgHex: string,
128
- fgHex: string,
129
- ratio: number,
130
- ): string {
131
- const [br, bg, bb] = hexToRgb(bgHex)
132
- const [fr, fg, fb] = hexToRgb(fgHex)
133
- const inv = 1 - ratio
134
- return rgbToHex(
135
- br * inv + fr * ratio,
136
- bg * inv + fg * ratio,
137
- bb * inv + fb * ratio,
138
- )
139
- }
140
-
141
100
  /**
142
101
  * Get the hex color for a series index.
143
102
  * Index 0 returns the accent color as-is.