π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
β test(utils): match chroma-js 3.3's exact hex alpha in colorUtils (#22769)
Rdmclin24bc911a3ba0d
diff --git a/apps/desktop/pnpm-lock.yaml b/apps/desktop/pnpm-lock.yamlindex 0653b6aa487..4752e861d71 100644--- a/apps/desktop/pnpm-lock.yaml+++ b/apps/desktop/pnpm-lock.yaml@@ -728,8 +728,8 @@ importers:specifier: ^3.0.1version: 3.0.1chroma-js:- specifier: ^3.2.0- version: 3.2.0+ specifier: ^3.3.0+ version: 3.3.0countries-and-timezones:specifier: ^3.9.0version: 3.10.0@@ -4161,6 +4161,9 @@ packages:resolution: {integrity: sha512-os/OippSlX1RlWWr+QDPcGUZs0uoqr32urfxESG9U93lhUfbnlyckte84Q8P1UQY/qth983AS1JONKmLS4T0nw==}+ resolution: {integrity: sha512-afEEP0zHO4dxwrqTllKSFWs83+u+htEsmyvSe8IPjKjrfy3qmNk+vpWAdpbA2fJa14LTgkGyemC74J6v3HSUZA==}+resolution: {integrity: sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==}@@ -11540,6 +11543,8 @@ snapshots:+ [email protected]: {}+diff --git a/package.json b/package.jsonindex 933341d9a7c..a3810f01038 100644--- a/package.json+++ b/package.json@@ -377,7 +377,7 @@"brotli-wasm": "^3.0.1","buffer.js": "npm:buffer@^6.0.3","chat": "~4.38.0",- "chroma-js": "^3.2.0",+ "chroma-js": "^3.3.0","class-variance-authority": "^0.7.1","cmdk": "^1.1.1","cookie": "^1.1.1",diff --git a/packages/utils/package.json b/packages/utils/package.jsonindex 61a0cedc2d3..5950290155e 100644--- a/packages/utils/package.json+++ b/packages/utils/package.json@@ -19,7 +19,7 @@"@lobechat/types": "workspace:*","@vercel/functions": "^3.7.4","brotli-wasm": "^3.0.1",- "chroma-js": "^3.2.0",+ "chroma-js": "^3.3.0","countries-and-timezones": "^3.9.0","cron-parser": "^5.10.1","dayjs": "^1.11.21",diff --git a/packages/utils/src/colorUtils.test.ts b/packages/utils/src/colorUtils.test.tsindex 68fde83a92a..041e2e5936c 100644--- a/packages/utils/src/colorUtils.test.ts+++ b/packages/utils/src/colorUtils.test.ts@@ -62,8 +62,9 @@ describe('colorUtils', () => {// Using hex with alphaconst result = convertAlphaToSolid('#ff000080', '#ffffff');- // #ff000080 is red with 50% opacity (80 in hex = 128/255 β 0.5)- expect(result).toBe('#ff8080');+ // 80 in hex is an alpha of exactly 128/255 (β 0.502), which chroma-js+ // reads unrounded since 3.3.0: 255 * (1 - 128/255) = 127 β 7f+ expect(result).toBe('#ff7f7f');});it('should handle named colors', () => {@@ -180,9 +181,10 @@ describe('colorUtils', () => {});it('should produce same result regardless of input color format', () => {+ // The same alpha in every format: hex `80` is exactly 128/255.const result1 = convertAlphaToSolid('#ff000080', '#ffffff');- const result2 = convertAlphaToSolid('rgba(255, 0, 0, 0.5)', 'white');- const result3 = convertAlphaToSolid('rgba(255, 0, 0, 0.5)', '#fff');+ const result2 = convertAlphaToSolid(`rgba(255, 0, 0, ${128 / 255})`, 'white');+ const result3 = convertAlphaToSolid(`rgba(255, 0, 0, ${128 / 255})`, '#fff');expect(result1).toBe(result2);expect(result2).toBe(result3);