|
1 |
| -import type { Highlighter, Lang } from 'shiki' |
2 |
| -import { getHighlighter } from 'shiki' |
| 1 | +import type { HighlighterCore } from 'shiki' |
| 2 | +import { createHighlighterCore } from 'shiki/core' |
| 3 | +import { createJavaScriptRegexEngine } from 'shiki/engine/javascript' |
3 | 4 | import { computed, ref, toValue } from 'vue'
|
4 | 5 | import type { MaybeRef } from '@vueuse/core'
|
5 | 6 | import { devtools } from './rpc'
|
6 | 7 |
|
7 |
| -export const shiki = ref<Highlighter>() |
| 8 | +export const shiki = ref<HighlighterCore>() |
8 | 9 |
|
9 | 10 | export function loadShiki() {
|
10 | 11 | // Only loading when needed
|
11 |
| - return getHighlighter({ |
| 12 | + return createHighlighterCore({ |
12 | 13 | themes: [
|
13 |
| - 'vitesse-dark', |
14 |
| - 'vitesse-light', |
| 14 | + import('@shikijs/themes/vitesse-light'), |
| 15 | + import('@shikijs/themes/vitesse-dark'), |
15 | 16 | ],
|
16 | 17 | langs: [
|
17 |
| - 'css', |
18 |
| - 'javascript', |
19 |
| - 'typescript', |
20 |
| - 'html', |
21 |
| - 'vue', |
22 |
| - 'vue-html', |
23 |
| - 'bash', |
24 |
| - 'diff', |
| 18 | + import('@shikijs/langs/json'), |
25 | 19 | ],
|
| 20 | + engine: createJavaScriptRegexEngine(), |
26 | 21 | }).then((i) => {
|
27 | 22 | shiki.value = i
|
28 | 23 | })
|
29 | 24 | }
|
30 | 25 |
|
31 |
| -export function renderCodeHighlight(code: MaybeRef<string>, lang?: Lang) { |
| 26 | +export function renderCodeHighlight(code: MaybeRef<string>, lang: 'json') { |
32 | 27 | return computed(() => {
|
33 | 28 | const colorMode = devtools.value?.colorMode || 'light'
|
34 | 29 | return shiki.value!.codeToHtml(toValue(code), {
|
|
0 commit comments