aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/shiki.bundle.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-03-10 01:21:18 +0900
committernsfisis <nsfisis@gmail.com>2025-03-10 01:21:18 +0900
commitc44b3383a7e55553cc95bba7bd5574f71c2e3406 (patch)
tree70e22e27b02b816b47c524c62258e262d49ddd3b /frontend/app/shiki.bundle.ts
parent84f3996f48d7a962685edfc09f12b8684cc76d93 (diff)
downloadiosdc-japan-2025-albatross-c44b3383a7e55553cc95bba7bd5574f71c2e3406.tar.gz
iosdc-japan-2025-albatross-c44b3383a7e55553cc95bba7bd5574f71c2e3406.tar.zst
iosdc-japan-2025-albatross-c44b3383a7e55553cc95bba7bd5574f71c2e3406.zip
feat(frontend): use fine-grained bundle of shiki
Diffstat (limited to 'frontend/app/shiki.bundle.ts')
-rw-r--r--frontend/app/shiki.bundle.ts58
1 files changed, 58 insertions, 0 deletions
diff --git a/frontend/app/shiki.bundle.ts b/frontend/app/shiki.bundle.ts
new file mode 100644
index 0000000..1d03de3
--- /dev/null
+++ b/frontend/app/shiki.bundle.ts
@@ -0,0 +1,58 @@
+/* Generate by @shikijs/codegen */
+import type {
+ DynamicImportLanguageRegistration,
+ DynamicImportThemeRegistration,
+ HighlighterGeneric,
+} from '@shikijs/types'
+import {
+ createSingletonShorthands,
+ createdBundledHighlighter,
+} from '@shikijs/core'
+import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript'
+
+type BundledLanguage = 'php'
+type BundledTheme = 'github-light'
+type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>
+
+const bundledLanguages = {
+ php: () => import('@shikijs/langs/php'),
+} as Record<BundledLanguage, DynamicImportLanguageRegistration>
+
+const bundledThemes = {
+ 'github-light': () => import('@shikijs/themes/github-light'),
+} as Record<BundledTheme, DynamicImportThemeRegistration>
+
+const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
+ BundledLanguage,
+ BundledTheme
+>({
+ langs: bundledLanguages,
+ themes: bundledThemes,
+ engine: () => createJavaScriptRegexEngine(),
+})
+
+const {
+ codeToHtml,
+ codeToHast,
+ codeToTokensBase,
+ codeToTokens,
+ codeToTokensWithThemes,
+ getSingletonHighlighter,
+ getLastGrammarState,
+} = /* @__PURE__ */ createSingletonShorthands<BundledLanguage, BundledTheme>(
+ createHighlighter,
+)
+
+export {
+ bundledLanguages,
+ bundledThemes,
+ codeToHast,
+ codeToHtml,
+ codeToTokens,
+ codeToTokensBase,
+ codeToTokensWithThemes,
+ createHighlighter,
+ getLastGrammarState,
+ getSingletonHighlighter,
+}
+export type { BundledLanguage, BundledTheme, Highlighter }