feat: add parseColor runtime and metro support for it#312
Conversation
📝 WalkthroughWalkthroughA new color parsing utility function is introduced that handles custom color formats through color functions like hsl() and oklch(), integrated into the runtime and consumed by the color processor to resolve CSS variable-based colors. Changes
Sequence Diagram(s)sequenceDiagram
participant ColorProcessor as Color.processColor<br/>(Processor)
participant Runtime as rt.parseColor<br/>(Runtime)
participant NativeUtil as parseColor<br/>(Utility)
participant Culori as Culori Library
ColorProcessor->>ColorProcessor: Detect function name<br/>via regex (hsl, oklch, etc.)
ColorProcessor->>Runtime: Call parseColor(type, value)
Runtime->>NativeUtil: Delegate to parseColor()
NativeUtil->>NativeUtil: Build color string<br/>e.g., "hsl(color)"
NativeUtil->>Culori: Parse with culori
Culori->>NativeUtil: Return parsed color
NativeUtil->>NativeUtil: Select output format<br/>(hex vs hex + alpha)
NativeUtil->>Runtime: Return hex color string
Runtime->>ColorProcessor: Return hex result
ColorProcessor->>ColorProcessor: Use resolved color
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/uniwind/src/core/native/native-utils.ts`:
- Around line 43-58: parseColor currently returns the raw input string when
parse(...) yields undefined, which can leak non-hex values; change parseColor so
that it always returns a hex/hex8 string by replacing the "if (parsedColor ===
undefined) return color" branch with a consistent hex fallback (e.g., return
'#000000'), and keep the existing catch returning '#000000'; refer to the
parseColor function and the helpers parse, formatHex, and formatHex8 when making
this change.
fixes #305
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.