mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
* fix(studio): parse modern CSS colors without a new dependency * refactor(studio): one colour parser for the text toolbar, stricter rgb numbers The inline text toolbar kept its own canvas fallback for named colours. parseCssColor now resolves them, so the toolbar uses it alone. rgb() channels must be well-formed numbers; that replaces the NaN check after parsing and rejects rgb(1. 2 3) as CSS does. * refactor(studio): drop comment lines the comment ratchet refuses in colorValue * fix(studio): linear-time rgb() patterns and no new colour literal in the parser The rgb() number pattern now has one way to match each digit run, which clears CodeQL's slow-regex alerts. The canvas reset uses transparent so the Studio colour-literal ratchet stays at its baseline. * fix(studio): legacy colours resolve in browsers without relative colour syntax parseBrowserColor reads the colour itself from the canvas first and accepts a #rrggbb or rgba() result, then tries color(from ...). Named, hsl() and percent rgb() colours resolve again in the text toolbar on Chrome before 119 and Safari 17. * test(studio): a colour the canvas rejects parses to null, not transparent black * fix(studio): an inserted gradient stop takes the colour the gradient paints there The stop colour is color-mix() in oklab, or srgb when both stops are legacy, resolved by the browser, so it matches the painted midpoint including premultiplied alpha; the channel blend stays as the fallback. The parser tries color(from ...) before the legacy read, keeping alpha precise, and calls CSS.supports inside its try. A Chrome-147-shaped fake canvas covers the modern path in unit tests. * test(studio): keep the fake browser canvas inside its test file * fix(studio): mix an inserted gradient stop in the space the whole gradient uses * fix(studio): let an unresolved var() stop keep a legacy gradient in sRGB * fix(studio): only a bare var() stop leaves the gradient space to its neighbours * fix(studio): pick light-dark() text colour from what the element paints * refactor(studio): drop the neighbour clause the whole-gradient check already covers * fix(studio): resolve the picker colour from the element that paints the selected text * fix(studio): read the picker colour from the character the swatch colour came from --------- Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com>