Skip to content

Commit f4df34e

Browse files
committed
chore: upgrade to new shiki api
1 parent 6011903 commit f4df34e

File tree

1 file changed

+6
-6
lines changed
  • apps/api-reference/src/components/Code

1 file changed

+6
-6
lines changed

apps/api-reference/src/components/Code/shiki.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import type { HighlighterCore, DecorationItem } from "shiki/core";
22
import { createHighlighterCore } from "shiki/core";
3+
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
34
import javascript from "shiki/langs/javascript.mjs";
45
import json from "shiki/langs/json.mjs";
56
import solidity from "shiki/langs/solidity.mjs";
67
import darkPlus from "shiki/themes/dark-plus.mjs";
78
import lightPlus from "shiki/themes/light-plus.mjs";
8-
import loadWasm from "shiki/wasm";
99

1010
import type { SupportedLanguage } from "./supported-language";
1111

1212
export type Highlighter = {
1313
highlight: (
1414
lang: SupportedLanguage | undefined,
1515
code: string,
16-
options?: HighlightOptions | undefined,
16+
options?: HighlightOptions,
1717
) => string;
1818
};
1919

@@ -22,17 +22,17 @@ export type HighlightOptions = {
2222
};
2323

2424
export const getHighlighter = async (): Promise<Highlighter> => {
25-
const highlighterCore = await shikiGetHighlighterCore({
25+
const highlighterCore = await createHighlighterCore({
2626
langs: [javascript, solidity, json],
2727
themes: [darkPlus, lightPlus],
28-
loadWasm,
28+
engine: createOnigurumaEngine(() => import("shiki/wasm")),
2929
});
3030

3131
return {
3232
highlight: (
3333
lang: SupportedLanguage | undefined,
3434
code: string,
35-
options?: HighlightOptions | undefined,
35+
options?: HighlightOptions,
3636
) => highlight(highlighterCore, lang, code, options),
3737
};
3838
};
@@ -41,7 +41,7 @@ const highlight = (
4141
highlighter: HighlighterCore,
4242
lang: SupportedLanguage | undefined,
4343
code: string,
44-
options?: HighlightOptions | undefined,
44+
options?: HighlightOptions,
4545
) =>
4646
highlighter.codeToHtml(code, {
4747
lang: lang ?? "text",

0 commit comments

Comments
 (0)