import { createShiki } from '~/utils/shiki' import { type HighlighterCore } from 'shiki/core' import { expose } from 'comlink' let shiki: HighlighterCore | null = null const api = { async init() { if (shiki) return shiki = await createShiki() }, async codeToHtml(code: string, options: { lang: string, themes: { light: string, dark: string } }) { if (!shiki) throw new Error('shiki not initialized') return shiki.codeToHtml(code, options) }, async getLanguage(lang: string) { if (!shiki) throw new Error('shiki not initialized') const grammar = shiki.getLanguage(lang); return { name: grammar.name } } } expose(api) export type ShikiWorker = typeof api