(options, callback)
| 216 | getThemes: () => [DEFAULT_LIGHT_THEME as ThemeInput, DEFAULT_DARK_THEME as ThemeInput], |
| 217 | supportsLanguage: (language: string) => isSupportedLang(language), |
| 218 | highlight(options, callback) { |
| 219 | const resolved = resolveLang(options.language); |
| 220 | const lang = resolved ?? "json"; |
| 221 | // Dual-theme tokens (light-dark() colors): correct in both color |
| 222 | // schemes, so the cache never holds the wrong palette and a mid-stream |
| 223 | // scheme flip needs no re-render. |
| 224 | const key = `${lang}:${options.code.length}:${options.code.slice(0, 128)}`; |
| 225 | |
| 226 | const cached = tokensCache.get(key); |
| 227 | if (cached) return cached; |
| 228 | |
| 229 | const isReady = ensureLang(lang, () => { |
| 230 | // Language just loaded — highlight and notify via callback |
| 231 | const result = highlighter.codeToTokens(options.code, { lang, ...dualThemeOptions() }); |
| 232 | tokensCache.set(key, result); |
| 233 | callback?.(result); |
| 234 | }); |
| 235 | |
| 236 | if (!isReady) return null; |
| 237 | |
| 238 | const result = highlighter.codeToTokens(options.code, { lang, ...dualThemeOptions() }); |
| 239 | tokensCache.set(key, result); |
| 240 | return result; |
| 241 | }, |
| 242 | }; |
| 243 | } |
nothing calls this directly
no test coverage detected