kaplay styled-text styles desync after emoji / astral CJK (grapheme vs UTF-16)
fix: align styled-text style positions with grapheme clusters
kaplay · kaplayjs/kaplay
compileStyledText builds charStyleMap keyed by UTF-16 code-unit length, but formatText later applies the styles by grapheme index (via runes()). The two indexings match for ASCII, but drift apart after any character longer than one code unit: an emoji, a ZWJ sequence, or an astral-plane CJK ideograph (CJK Extension B, e.g. names written with 𠮷). Every style after such a character lands on the wrong grapheme or is dropped.
In styled text, "😀[c]x[/c]" keys the colour style at code unit 2, but runes("😀x") puts x at grapheme index 1, so the style is lost.
Make compileStyledText walk grapheme clusters with the same runes() helper formatText already uses, keying charStyleMap by grapheme index. Normalize the input to NFC up front and consume a whole grapheme per escape so the slice lengths stay consistent.