@@ -3,6 +3,7 @@ import type { OperationData } from '@/lib/operation/operationData'
33import type { LanguageConfig } from ' ../../composables/useTheme'
44import { OPERATION_DATA_KEY } from ' @/lib/operation/operationData'
55import { inject , ref , watch } from ' vue'
6+ import { useShiki } from ' ../../composables/useShiki'
67import { useTheme } from ' ../../composables/useTheme'
78import OACodeBlock from ' ../Common/OACodeBlock.vue'
89
@@ -24,6 +25,8 @@ const operationData = inject(OPERATION_DATA_KEY) as OperationData
2425
2526const themeConfig = useTheme ()
2627
28+ const shiki = useShiki ()
29+
2730const availableLanguages = themeConfig .getCodeSamplesAvailableLanguages ()
2831
2932const generator = themeConfig .getCodeSamplesGenerator ()
@@ -83,6 +86,15 @@ watch(operationData.playground.request, async (playgroundRequest, _, onInvalidat
8386 if (cancelled ) {
8487 return
8588 }
89+
90+ // Preload all highlighter languages
91+ const uniqueHighlighters = [... new Set (nextSamples .map (s => s .highlighter ).filter (Boolean ))]
92+ await Promise .all (uniqueHighlighters .map (lang => shiki .ensureLanguage (lang )))
93+
94+ if (cancelled ) {
95+ return
96+ }
97+
8698 samples .value = nextSamples
8799
88100 if (! activeSampleKey .value || ! samples .value .some (s => s .key === activeSampleKey .value )) {
@@ -94,6 +106,7 @@ watch(operationData.playground.request, async (playgroundRequest, _, onInvalidat
94106 }
95107}, {
96108 deep: true ,
109+ immediate: true ,
97110})
98111 </script >
99112
0 commit comments