1
1
import type { HighlighterCore , DecorationItem } from "shiki/core" ;
2
2
import { createHighlighterCore } from "shiki/core" ;
3
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma" ;
3
4
import javascript from "shiki/langs/javascript.mjs" ;
4
5
import json from "shiki/langs/json.mjs" ;
5
6
import solidity from "shiki/langs/solidity.mjs" ;
6
7
import darkPlus from "shiki/themes/dark-plus.mjs" ;
7
8
import lightPlus from "shiki/themes/light-plus.mjs" ;
8
- import loadWasm from "shiki/wasm" ;
9
9
10
10
import type { SupportedLanguage } from "./supported-language" ;
11
11
12
12
export type Highlighter = {
13
13
highlight : (
14
14
lang : SupportedLanguage | undefined ,
15
15
code : string ,
16
- options ?: HighlightOptions | undefined ,
16
+ options ?: HighlightOptions ,
17
17
) => string ;
18
18
} ;
19
19
@@ -22,17 +22,17 @@ export type HighlightOptions = {
22
22
} ;
23
23
24
24
export const getHighlighter = async ( ) : Promise < Highlighter > => {
25
- const highlighterCore = await shikiGetHighlighterCore ( {
25
+ const highlighterCore = await createHighlighterCore ( {
26
26
langs : [ javascript , solidity , json ] ,
27
27
themes : [ darkPlus , lightPlus ] ,
28
- loadWasm ,
28
+ engine : createOnigurumaEngine ( ( ) => import ( "shiki/wasm" ) ) ,
29
29
} ) ;
30
30
31
31
return {
32
32
highlight : (
33
33
lang : SupportedLanguage | undefined ,
34
34
code : string ,
35
- options ?: HighlightOptions | undefined ,
35
+ options ?: HighlightOptions ,
36
36
) => highlight ( highlighterCore , lang , code , options ) ,
37
37
} ;
38
38
} ;
@@ -41,7 +41,7 @@ const highlight = (
41
41
highlighter : HighlighterCore ,
42
42
lang : SupportedLanguage | undefined ,
43
43
code : string ,
44
- options ?: HighlightOptions | undefined ,
44
+ options ?: HighlightOptions ,
45
45
) =>
46
46
highlighter . codeToHtml ( code , {
47
47
lang : lang ?? "text" ,
0 commit comments