char/sorcery
static-files based git repo viewer
git clone https://git.t4t.associates/char/sorcery
85f1b9e
main
1import { availableLanguages , highlight } from "@arborium/arborium" ; 2 3export interface HighlightRequest { 4id :number ; 5language :string ; 6source :string ; 7} 8 9export type HighlightReply = { id :number ; html :string | null } | { id :number ; error :string }; 10 11const available = new Set < string >( availableLanguages ); 12 13onmessage = async ({ data :{ id, language, source} } :MessageEvent < HighlightRequest >) => { 14let reply :HighlightReply ; 15try { 16reply = { id, html :available . has ( language ) ?await highlight ( language , source ) :null }; 17} catch ( error ) { 18reply = { id, error :String ( error ) }; 19} 20postMessage ( reply ); 21};