Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit d187e53

Browse files
committedDec 15, 2023
feat: provide more info for languages and themes
1 parent fbf8082 commit d187e53

19 files changed

+1580
-500
lines changed
 

‎docs/.vitepress/components/ShikijiMiniPlayground.vue

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,35 @@
22
import { usePlayground } from '../store/playground'
33
44
const play = usePlayground()
5-
6-
function randomize() {
7-
play.lang = play.allLanguages[Math.floor(Math.random() * play.allLanguages.length)]
8-
play.theme = play.allThemes[Math.floor(Math.random() * play.allThemes.length)]
9-
}
105
</script>
116

127
<template>
138
<div class="language-ts vp-adaptive-theme mini-playground" shadow :style="play.preStyle">
149
<div absolute z-10 p2 px3 pl5 flex="~ gap-1 items-center" left-0 top-0 right-0 border="b-solid gray/5">
1510
<div i-carbon:chevron-down op50 />
1611
<select v-model="play.lang" font-mono>
17-
<option v-for="lang in play.allLanguages" :key="lang" :value="lang">
18-
{{ lang }}
12+
<option v-for="lang in play.allLanguages" :key="lang.id" :value="lang.id">
13+
{{ lang.name }}
1914
</option>
2015
</select>
2116
<div i-carbon:chevron-down op50 />
2217
<select v-model="play.theme" font-mono>
23-
<option v-for="theme in play.allThemes" :key="theme" :value="theme">
24-
{{ theme }}
18+
<option v-for="theme in play.allThemes.filter(i => i.type === 'light')" :key="theme.id" :value="theme.id">
19+
{{ theme.name }}
20+
</option>
21+
<option disabled>
22+
──────────
23+
</option>
24+
<option v-for="theme in play.allThemes.filter(i => i.type === 'dark')" :key="theme.id" :value="theme.id">
25+
{{ theme.name }}
2526
</option>
2627
</select>
2728
<div flex-auto />
29+
<div v-if="play.isLoading" svg-spinners:270-ring />
2830
<div op50 text-xs mr-2>
2931
Playground
3032
</div>
31-
<button title="Randomize" hover="bg-gray/10" p1 rounded @click="randomize">
33+
<button title="Randomize" hover="bg-gray/10" p1 rounded @click="play.randomize">
3234
<div i-carbon:shuffle op50 />
3335
</button>
3436
</div>

‎docs/.vitepress/components/ShikijiPlayground.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ const play = usePlayground()
66

77
<template>
88
<div class="vp-doc">
9-
<h1>WIP</h1>
10-
<div grid="~ cols-2">
11-
<textarea v-model="play.input" />
12-
<div v-html="play.output" />
9+
<div grid="~ cols-2 gap-4" p4>
10+
<textarea v-model="play.input" font-mono rounded p4 my4.5 />
11+
<ShikijiMiniPlayground />
1312
</div>
1413
</div>
1514
</template>

‎docs/.vitepress/store/playground.ts

+54-23
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,81 @@
11
/// <reference types="vite/client" />
22

33
import { acceptHMRUpdate, defineStore } from 'pinia'
4-
import type { BuiltinLanguage, BuiltinTheme } from 'shikiji'
4+
import type { BuiltinLanguage, BuiltinTheme, BundledLanguageInfo, BundledThemeInfo } from 'shikiji'
55
import { useLocalStorage } from '@vueuse/core'
6-
import { ref, watch } from 'vue'
6+
import { ref, shallowRef, watch } from 'vue'
77

88
export const usePlayground = defineStore('playground', () => {
99
const lang = useLocalStorage<BuiltinLanguage>('shikiji-playground-lang', 'typescript')
1010
const theme = useLocalStorage<BuiltinTheme>('shikiji-playground-theme', 'vitesse-dark')
11-
const allThemes = ref<BuiltinTheme[]>([])
12-
const allLanguages = ref<BuiltinLanguage[]>([])
13-
const input = ref('console.log(\'Hello World\')')
11+
const allThemes = shallowRef<BundledThemeInfo[]>([
12+
{
13+
id: 'vitesse-dark',
14+
name: 'Vitesse Dark',
15+
type: 'dark',
16+
import: undefined!,
17+
},
18+
])
19+
const allLanguages = shallowRef<BundledLanguageInfo[]>([
20+
{
21+
id: 'typescript',
22+
name: 'TypeScript',
23+
import: undefined!,
24+
},
25+
])
26+
const input = useLocalStorage('shikiji-playground-input', '')
1427
const output = ref('<pre></pre>')
1528
const preStyle = ref('')
1629
const isLoading = ref(true)
1730

31+
function randomize() {
32+
if (allLanguages.value.length && allThemes.value.length) {
33+
lang.value = allLanguages.value[Math.floor(Math.random() * allLanguages.value.length)].id as any
34+
theme.value = allThemes.value[Math.floor(Math.random() * allThemes.value.length)].id as any
35+
}
36+
}
37+
1838
if (typeof window !== 'undefined') {
19-
import('shikiji').then(async ({ getHighlighter, addClassToHast, bundledLanguages, bundledThemes }) => {
39+
(async () => {
40+
const { getHighlighter, addClassToHast } = await import('shikiji')
41+
const { bundledLanguagesInfo } = await import('shikiji/langs')
42+
const { bundledThemesInfo } = await import('shikiji/themes')
2043
const highlighter = await getHighlighter({
2144
themes: [theme.value],
22-
langs: ['typescript', 'javascript', 'json', 'html', 'css', 'markdown', lang.value as any],
45+
langs: ['typescript', 'javascript', lang.value as any],
2346
})
2447

25-
const samples = Object.fromEntries(
26-
Array.from(
27-
Object.entries(import.meta.glob('../../node_modules/shiki/samples/*.sample', {
28-
exhaustive: true,
29-
as: 'raw',
30-
})),
31-
).map(([path, load]) => [path.split(/\//).pop()!.split(/\./).shift()!, load]),
32-
)
48+
const samplesCache = new Map<string, Promise<string | undefined>>()
49+
50+
function fetchSample(id: string) {
51+
if (!samplesCache.has(id)) {
52+
samplesCache.set(id, fetch(`https://raw.githubusercontent.com/shikijs/shiki/main/packages/shiki/samples/${id}.sample`)
53+
.then(r => r.text())
54+
.catch((e) => {
55+
console.error(e)
56+
return undefined
57+
}))
58+
}
59+
return samplesCache.get(id)!
60+
}
3361

34-
allThemes.value = Object.keys(bundledThemes) as any
35-
allLanguages.value = Object.keys(bundledLanguages) as any
62+
allThemes.value = bundledThemesInfo
63+
allLanguages.value = bundledLanguagesInfo
3664

3765
watch(input, run, { immediate: true })
3866

39-
watch([lang, theme], async () => {
67+
watch([lang, theme], async (n, o) => {
4068
isLoading.value = true
4169
await Promise.all([
4270
highlighter.loadTheme(theme.value),
4371
highlighter.loadLanguage(lang.value as any),
4472
])
45-
const grammar = highlighter.getLangGrammar(lang.value) as any
46-
const sample = await samples[grammar?._grammar?.name || lang.value]?.()
47-
if (sample)
48-
input.value = sample.replace(/\n.*?From.*?$/im, '').trim()
73+
// Fetch sample if language changed
74+
if ((o[0] || !input.value) && n[0] !== o[0]) {
75+
const sample = await fetchSample(lang.value)
76+
if (sample)
77+
input.value = sample.replace(/\n.*?From.*?$/im, '').trim()
78+
}
4979
run()
5080
}, { immediate: true })
5181

@@ -64,7 +94,7 @@ export const usePlayground = defineStore('playground', () => {
6494
})
6595
isLoading.value = false
6696
}
67-
})
97+
})()
6898
}
6999

70100
return {
@@ -76,6 +106,7 @@ export const usePlayground = defineStore('playground', () => {
76106
output,
77107
isLoading,
78108
preStyle,
109+
randomize,
79110
}
80111
})
81112

‎docs/.vitepress/theme/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ import 'shikiji-twoslash/style-rich.css'
66
import './style.css'
77
import './custom.css'
88
import { createPinia } from 'pinia'
9-
import HomeDemo from '../components/HomeDemo.vue'
109

1110
export default {
1211
extends: Theme,
1312
Layout: () => {
14-
return h(Theme.Layout, null, {
15-
'home-features-after': () => h(HomeDemo),
16-
})
13+
return h(Theme.Layout, null, {})
1714
},
1815
enhanceApp({ app }: any) {
1916
app.use(createPinia())

‎docs/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ features:
3030
icon: 🎄
3131
details: Fully tree-shakable ESM, runs on any JavaScript runtime, including Browser, Node.js, Cloudflare Workers, etc.
3232
---
33+
34+
<HomeDemo />

‎docs/languages.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Inherited from [`shiki`](https://github.com/shikijs/shiki/blob/main/docs/languag
3737
| `crystal` | Crystal | |
3838
| `csharp` | C# | `c#`, `cs` |
3939
| `css` | CSS | |
40+
| `csv` | csv syntax | |
4041
| `cue` | CUE | |
4142
| `cypher` | Cypher | `cql` |
4243
| `d` | D | |
@@ -108,6 +109,7 @@ Inherited from [`shiki`](https://github.com/shikijs/shiki/blob/main/docs/languag
108109
| `nginx` | Nginx | |
109110
| `nim` | Nim | |
110111
| `nix` | Nix | |
112+
| `nushell` | nushell | `nu` |
111113
| `objective-c` | Objective-C | `objc` |
112114
| `objective-cpp` | Objective-C++ | |
113115
| `ocaml` | OCaml | |
@@ -172,7 +174,7 @@ Inherited from [`shiki`](https://github.com/shikijs/shiki/blob/main/docs/languag
172174
| `wasm` | WebAssembly | |
173175
| `wenyan` | Wenyan | `文言` |
174176
| `wgsl` | WGSL | |
175-
| `wolfram` | Wolfram | |
177+
| `wolfram` | Wolfram | `wl` |
176178
| `xml` | XML | |
177179
| `xsl` | XSL | |
178180
| `yaml` | YAML | `yml` |

‎docs/package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@
1010
"fuse.js": "^7.0.0"
1111
},
1212
"devDependencies": {
13-
"@types/markdown-it-container": "^2.0.9",
1413
"@unocss/reset": "^0.58.0",
1514
"@vueuse/core": "^10.7.0",
16-
"gray-matter": "^4.0.3",
17-
"markdown-it-container": "^3.0.0",
1815
"pinia": "^2.1.7",
19-
"shiki": "^0.14.6",
16+
"shiki": "^0.14.7",
2017
"shikiji": "workspace:*",
2118
"shikiji-transformers": "workspace:*",
2219
"shikiji-twoslash": "workspace:*",
2320
"unocss": "^0.58.0",
2421
"unplugin-vue-components": "^0.26.0",
2522
"vitepress": "1.0.0-rc.30",
26-
"vue": "^3.3.10"
23+
"vue": "^3.3.11"
2724
}
2825
}

‎docs/themes.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ Inherited from [`shiki`](https://github.com/shikijs/shiki/blob/main/docs/themes.
77
<!--all-themes:start-->
88
| ID |
99
| --- |
10-
| `css-variables` |
1110
| `dark-plus` |
1211
| `dracula` |
1312
| `dracula-soft` |
1413
| `github-dark` |
1514
| `github-dark-dimmed` |
1615
| `github-light` |
17-
| `hc_light` |
1816
| `light-plus` |
1917
| `material-theme` |
2018
| `material-theme-darker` |
@@ -34,6 +32,7 @@ Inherited from [`shiki`](https://github.com/shikijs/shiki/blob/main/docs/themes.
3432
| `slack-ochin` |
3533
| `solarized-dark` |
3634
| `solarized-light` |
35+
| `vitesse-black` |
3736
| `vitesse-dark` |
3837
| `vitesse-light` |
3938
<!--all-themes:end-->

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"docs:build": "pnpm -C docs run docs:build"
1414
},
1515
"devDependencies": {
16-
"@antfu/eslint-config": "^2.4.5",
16+
"@antfu/eslint-config": "^2.4.6",
1717
"@antfu/ni": "^0.21.12",
1818
"@antfu/utils": "^0.7.7",
1919
"@rollup/plugin-alias": "^5.1.0",
@@ -28,8 +28,8 @@
2828
"@vitest/coverage-v8": "^1.0.4",
2929
"ansi-sequence-parser": "^1.1.1",
3030
"bumpp": "^9.2.1",
31-
"eslint": "npm:eslint-ts-patch@8.55.0-1",
3231
"eslint-plugin-format": "^0.1.0",
32+
"eslint": "npm:eslint-ts-patch@8.55.0-1",
3333
"eslint-ts-patch": "8.55.0-1",
3434
"esno": "^4.0.0",
3535
"fast-glob": "^3.3.2",
@@ -46,16 +46,16 @@
4646
"rollup-plugin-dts": "^6.1.0",
4747
"rollup-plugin-esbuild": "^6.1.0",
4848
"rollup-plugin-typescript2": "^0.36.0",
49-
"shiki": "^0.14.6",
49+
"shiki": "^0.14.7",
5050
"shikiji": "workspace:*",
5151
"simple-git-hooks": "^2.9.0",
5252
"taze": "^0.13.0",
5353
"typescript": "^5.3.3",
5454
"unbuild": "^2.0.0",
55-
"vite": "^5.0.9",
55+
"vite": "^5.0.10",
5656
"vitest": "^1.0.4",
5757
"vue-tsc": "^1.8.25",
58-
"wrangler": "^3.20.0"
58+
"wrangler": "^3.21.0"
5959
},
6060
"pnpm": {
6161
"patchedDependencies": {

‎packages/shikiji-twoslash/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@iconify-json/carbon": "^1.1.26",
5656
"@iconify-json/codicon": "^1.1.39",
5757
"hast-util-from-html": "^2.0.1",
58-
"shiki": "^0.14.6",
58+
"shiki": "^0.14.7",
5959
"shiki-twoslash": "^3.1.2",
6060
"typescript": "^5.3.3"
6161
}

‎packages/shikiji/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"shikiji-core": "workspace:*"
7979
},
8080
"devDependencies": {
81-
"shiki": "^0.14.6",
81+
"shiki": "^0.14.7",
8282
"vscode-oniguruma": "^1.7.0"
8383
}
8484
}

‎packages/shikiji/rollup.config.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ export default defineConfig([
7979
await Promise.all(
8080
langs.map(file => fs.writeFile(
8181
join(dirname(file), `${basename(file, '.mjs')}.d.mts`),
82-
'import { LanguageRegistration } from \'../types.mjs\';declare const reg: LanguageRegistration[];export default reg',
82+
'import { LanguageRegistration } from \'shikiji-core\';declare const reg: LanguageRegistration[];export default reg',
8383
'utf-8',
8484
)),
8585
)
8686
const themes = await fg('dist/themes/*.mjs', { absolute: true })
8787
await Promise.all(
8888
themes.map(file => fs.writeFile(
8989
join(dirname(file), `${basename(file, '.mjs')}.d.mts`),
90-
'import { ThemeRegistrationRaw } from \'../types.mjs\';declare const reg: ThemeRegistrationRaw;export default reg',
90+
'import { ThemeRegistrationRaw } from \'shikiji-core\';declare const reg: ThemeRegistrationRaw;export default reg',
9191
'utf-8',
9292
)),
9393
)

‎packages/shikiji/scripts/prepare.ts

+84-22
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for (const file of allLangFiles) {
4444
const embedded = (json.embeddedLangs || []) as string[]
4545

4646
await fs.writeFile(`./src/assets/langs/${lang.id}.ts`, `${comments}
47-
import { LanguageRegistration } from '../../types'
47+
import type { LanguageRegistration } from 'shikiji-core'
4848
4949
${embedded.map(i => `import ${i.replace(/[^\w]/g, '_')} from './${i}'`).join('\n')}
5050
@@ -62,32 +62,42 @@ ${[
6262
async function writeLanguageBundleIndex(fileName: string, ids: string[]) {
6363
const bundled = ids.map(id => BUNDLED_LANGUAGES.find(i => i.id === id)!)
6464

65-
const base = Object.fromEntries(
66-
bundled.map(i => [i.id, `__(() => import('./langs/${i.id}')) as DynamicLangReg__`])
67-
.sort((a, b) => a[0].localeCompare(b[0])),
68-
)
69-
const alias = Object.fromEntries(
70-
bundled.flatMap(i =>
71-
(i.aliases || []).map(x => [x, `__bundledLanguagesBase['${i.id}']__`]),
72-
)
73-
.sort((a, b) => a[0].localeCompare(b[0])),
74-
)
65+
const info = bundled.map(i => ({
66+
id: i.id,
67+
name: i.displayName,
68+
aliases: i.aliases,
69+
import: `__(() => import('./langs/${i.id}')) as DynamicLangReg__`,
70+
}) as const)
71+
.sort((a, b) => a.id.localeCompare(b.id))
72+
73+
const type = info.flatMap(i => [...i.aliases || [], i.id]).sort().map(i => `'${i}'`).join(' | ')
7574

7675
await fs.writeFile(
7776
`src/assets/${fileName}.ts`,
7877
`${comments}
79-
import type { LanguageRegistration } from '../types'
78+
import type { LanguageRegistration } from 'shikiji-core'
8079
8180
type DynamicLangReg = () => Promise<{ default: LanguageRegistration[] }>
8281
83-
export const bundledLanguagesBase = ${JSON.stringify(base, null, 2).replace(/"__|__"/g, '').replace(/"/g, '\'')}
82+
export interface BundledLanguageInfo {
83+
id: string
84+
name: string
85+
import: DynamicLangReg
86+
aliases?: string[]
87+
}
88+
89+
export const bundledLanguagesInfo: BundledLanguageInfo[] = ${JSON.stringify(info, null, 2).replace(/"__|__"/g, '').replace(/"/g, '\'')}
90+
91+
export const bundledLanguagesBase = Object.fromEntries(bundledLanguagesInfo.map(i => [i.id, i.import]))
8492
85-
export const bundledLanguagesAlias = ${JSON.stringify(alias, null, 2).replace(/"__|__"/g, '').replace(/"/g, '\'')}
93+
export const bundledLanguagesAlias = Object.fromEntries(bundledLanguagesInfo.flatMap(i => i.aliases?.map(a => [a, i.import]) || []))
94+
95+
export type BuiltinLanguage = ${type}
8696
8797
export const bundledLanguages = {
8898
...bundledLanguagesBase,
8999
...bundledLanguagesAlias,
90-
}
100+
} as Record<BuiltinLanguage, DynamicLangReg>
91101
`,
92102
'utf-8',
93103
)
@@ -106,26 +116,78 @@ export const bundledLanguages = {
106116
await writeLanguageBundleIndex('langs', BUNDLED_LANGUAGES.map(i => i.id))
107117
// await writeLanguageBundleIndex('langs-common', BundleCommonLangs)
108118

109-
const themes = Object.fromEntries(BUNDLED_THEMES.sort()
119+
const themes = BUNDLED_THEMES.sort()
110120
.filter(i => i !== 'css-variables')
111-
.map(i => [i, `__(() => import('shiki/themes/${i}.json')) as unknown as DynamicThemeReg__`]))
121+
.map((id) => {
122+
const theme = fs.readJSONSync(`./node_modules/shiki/themes/${id}.json`)
123+
124+
return {
125+
id,
126+
name: guessThemeName(id, theme),
127+
type: guessThemeType(id, theme),
128+
import: `__(() => import('shiki/themes/${id}.json')) as unknown as DynamicThemeReg__`,
129+
}
130+
})
112131

113132
await fs.writeFile(
114133
'src/assets/themes.ts',
115134
`${comments}
116-
import type { ThemeRegistrationRaw } from '../types'
135+
import type { ThemeRegistrationRaw } from 'shikiji-core'
117136
118137
type DynamicThemeReg = () => Promise<{ default: ThemeRegistrationRaw }>
119138
120-
export const bundledThemes = ${JSON.stringify(themes, null, 2).replace(/"__|__"/g, '')}
139+
export interface BundledThemeInfo {
140+
id: string
141+
name: string
142+
type: 'light' | 'dark'
143+
import: DynamicThemeReg
144+
}
145+
146+
export const bundledThemesInfo: BundledThemeInfo[] = ${JSON.stringify(themes, null, 2).replace(/"__|__"/g, '')}
147+
148+
export type BuiltinTheme = ${themes.map(i => `'${i.id}'`).join(' | ')}
149+
150+
export const bundledThemes = Object.fromEntries(bundledThemesInfo.map(i => [i.id, i.import])) as Record<BuiltinTheme, DynamicThemeReg>
121151
`,
122152
'utf-8',
123153
)
124154

125155
await fs.writeJSON(
126156
'src/assets/themes.json',
127-
BUNDLED_THEMES.map(i => ({
128-
id: i,
129-
})),
157+
BUNDLED_THEMES
158+
.filter(i => i !== 'css-variables')
159+
.map(i => ({
160+
id: i,
161+
})),
130162
{ spaces: 2 },
131163
)
164+
165+
function isLightColor(hex: string) {
166+
const [r, g, b] = hex.slice(1).match(/.{2}/g)!.map(i => Number.parseInt(i, 16))
167+
return (r * 299 + g * 587 + b * 114) / 1000 > 128
168+
}
169+
170+
function guessThemeType(id: string, theme: any) {
171+
let color = theme.type
172+
if (!['light', 'dark'].includes(color)) {
173+
if (id.includes('dark') || id.includes('dimmed') || id.includes('black'))
174+
color = 'dark'
175+
else if (theme.colors.background)
176+
color = isLightColor(theme.colors.background) ? 'light' : 'dark'
177+
else if (theme.colors['editor.background'])
178+
color = isLightColor(theme.colors['editor.background']) ? 'light' : 'dark'
179+
else
180+
color = 'light'
181+
console.log('guess', id, color)
182+
}
183+
return color
184+
}
185+
186+
function guessThemeName(id: string, theme: any) {
187+
if (theme.displayName)
188+
return theme.displayName
189+
let name: string = theme.name || id
190+
name = name.split(/[_-]/).map(i => i[0].toUpperCase() + i.slice(1)).join(' ')
191+
name = name.replace(/github/ig, 'GitHub')
192+
return name
193+
}

‎packages/shikiji/src/assets/langs.ts

+1,023-228
Large diffs are not rendered by default.

‎packages/shikiji/src/assets/themes.ts

+181-30
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,188 @@
11
/**
22
* Generated by scripts/prepare.ts
33
*/
4-
import type { ThemeRegistrationRaw } from '../types'
4+
import type { ThemeRegistrationRaw } from 'shikiji-core'
55

66
type DynamicThemeReg = () => Promise<{ default: ThemeRegistrationRaw }>
77

8-
export const bundledThemes = {
9-
"dark-plus": (() => import('shiki/themes/dark-plus.json')) as unknown as DynamicThemeReg,
10-
"dracula": (() => import('shiki/themes/dracula.json')) as unknown as DynamicThemeReg,
11-
"dracula-soft": (() => import('shiki/themes/dracula-soft.json')) as unknown as DynamicThemeReg,
12-
"github-dark": (() => import('shiki/themes/github-dark.json')) as unknown as DynamicThemeReg,
13-
"github-dark-dimmed": (() => import('shiki/themes/github-dark-dimmed.json')) as unknown as DynamicThemeReg,
14-
"github-light": (() => import('shiki/themes/github-light.json')) as unknown as DynamicThemeReg,
15-
"hc_light": (() => import('shiki/themes/hc_light.json')) as unknown as DynamicThemeReg,
16-
"light-plus": (() => import('shiki/themes/light-plus.json')) as unknown as DynamicThemeReg,
17-
"material-theme": (() => import('shiki/themes/material-theme.json')) as unknown as DynamicThemeReg,
18-
"material-theme-darker": (() => import('shiki/themes/material-theme-darker.json')) as unknown as DynamicThemeReg,
19-
"material-theme-lighter": (() => import('shiki/themes/material-theme-lighter.json')) as unknown as DynamicThemeReg,
20-
"material-theme-ocean": (() => import('shiki/themes/material-theme-ocean.json')) as unknown as DynamicThemeReg,
21-
"material-theme-palenight": (() => import('shiki/themes/material-theme-palenight.json')) as unknown as DynamicThemeReg,
22-
"min-dark": (() => import('shiki/themes/min-dark.json')) as unknown as DynamicThemeReg,
23-
"min-light": (() => import('shiki/themes/min-light.json')) as unknown as DynamicThemeReg,
24-
"monokai": (() => import('shiki/themes/monokai.json')) as unknown as DynamicThemeReg,
25-
"nord": (() => import('shiki/themes/nord.json')) as unknown as DynamicThemeReg,
26-
"one-dark-pro": (() => import('shiki/themes/one-dark-pro.json')) as unknown as DynamicThemeReg,
27-
"poimandres": (() => import('shiki/themes/poimandres.json')) as unknown as DynamicThemeReg,
28-
"rose-pine": (() => import('shiki/themes/rose-pine.json')) as unknown as DynamicThemeReg,
29-
"rose-pine-dawn": (() => import('shiki/themes/rose-pine-dawn.json')) as unknown as DynamicThemeReg,
30-
"rose-pine-moon": (() => import('shiki/themes/rose-pine-moon.json')) as unknown as DynamicThemeReg,
31-
"slack-dark": (() => import('shiki/themes/slack-dark.json')) as unknown as DynamicThemeReg,
32-
"slack-ochin": (() => import('shiki/themes/slack-ochin.json')) as unknown as DynamicThemeReg,
33-
"solarized-dark": (() => import('shiki/themes/solarized-dark.json')) as unknown as DynamicThemeReg,
34-
"solarized-light": (() => import('shiki/themes/solarized-light.json')) as unknown as DynamicThemeReg,
35-
"vitesse-dark": (() => import('shiki/themes/vitesse-dark.json')) as unknown as DynamicThemeReg,
36-
"vitesse-light": (() => import('shiki/themes/vitesse-light.json')) as unknown as DynamicThemeReg
8+
export interface BundledThemeInfo {
9+
id: string
10+
name: string
11+
type: 'light' | 'dark'
12+
import: DynamicThemeReg
3713
}
14+
15+
export const bundledThemesInfo: BundledThemeInfo[] = [
16+
{
17+
"id": "dark-plus",
18+
"name": "Dark Plus",
19+
"type": "dark",
20+
"import": (() => import('shiki/themes/dark-plus.json')) as unknown as DynamicThemeReg
21+
},
22+
{
23+
"id": "dracula",
24+
"name": "Dracula",
25+
"type": "dark",
26+
"import": (() => import('shiki/themes/dracula.json')) as unknown as DynamicThemeReg
27+
},
28+
{
29+
"id": "dracula-soft",
30+
"name": "Dracula Soft",
31+
"type": "dark",
32+
"import": (() => import('shiki/themes/dracula-soft.json')) as unknown as DynamicThemeReg
33+
},
34+
{
35+
"id": "github-dark",
36+
"name": "GitHub Dark",
37+
"type": "dark",
38+
"import": (() => import('shiki/themes/github-dark.json')) as unknown as DynamicThemeReg
39+
},
40+
{
41+
"id": "github-dark-dimmed",
42+
"name": "GitHub Dark Dimmed",
43+
"type": "dark",
44+
"import": (() => import('shiki/themes/github-dark-dimmed.json')) as unknown as DynamicThemeReg
45+
},
46+
{
47+
"id": "github-light",
48+
"name": "GitHub Light",
49+
"type": "dark",
50+
"import": (() => import('shiki/themes/github-light.json')) as unknown as DynamicThemeReg
51+
},
52+
{
53+
"id": "light-plus",
54+
"name": "Light Plus",
55+
"type": "light",
56+
"import": (() => import('shiki/themes/light-plus.json')) as unknown as DynamicThemeReg
57+
},
58+
{
59+
"id": "material-theme",
60+
"name": "Material Theme",
61+
"type": "dark",
62+
"import": (() => import('shiki/themes/material-theme.json')) as unknown as DynamicThemeReg
63+
},
64+
{
65+
"id": "material-theme-darker",
66+
"name": "Material Theme Darker",
67+
"type": "dark",
68+
"import": (() => import('shiki/themes/material-theme-darker.json')) as unknown as DynamicThemeReg
69+
},
70+
{
71+
"id": "material-theme-lighter",
72+
"name": "Material Theme Lighter",
73+
"type": "light",
74+
"import": (() => import('shiki/themes/material-theme-lighter.json')) as unknown as DynamicThemeReg
75+
},
76+
{
77+
"id": "material-theme-ocean",
78+
"name": "Material Theme Ocean",
79+
"type": "dark",
80+
"import": (() => import('shiki/themes/material-theme-ocean.json')) as unknown as DynamicThemeReg
81+
},
82+
{
83+
"id": "material-theme-palenight",
84+
"name": "Material Theme Palenight",
85+
"type": "dark",
86+
"import": (() => import('shiki/themes/material-theme-palenight.json')) as unknown as DynamicThemeReg
87+
},
88+
{
89+
"id": "min-dark",
90+
"name": "Min Dark",
91+
"type": "dark",
92+
"import": (() => import('shiki/themes/min-dark.json')) as unknown as DynamicThemeReg
93+
},
94+
{
95+
"id": "min-light",
96+
"name": "Min Light",
97+
"type": "light",
98+
"import": (() => import('shiki/themes/min-light.json')) as unknown as DynamicThemeReg
99+
},
100+
{
101+
"id": "monokai",
102+
"name": "Monokai",
103+
"type": "dark",
104+
"import": (() => import('shiki/themes/monokai.json')) as unknown as DynamicThemeReg
105+
},
106+
{
107+
"id": "nord",
108+
"name": "Nord",
109+
"type": "dark",
110+
"import": (() => import('shiki/themes/nord.json')) as unknown as DynamicThemeReg
111+
},
112+
{
113+
"id": "one-dark-pro",
114+
"name": "One Dark Pro",
115+
"type": "dark",
116+
"import": (() => import('shiki/themes/one-dark-pro.json')) as unknown as DynamicThemeReg
117+
},
118+
{
119+
"id": "poimandres",
120+
"name": "Poimandres",
121+
"type": "dark",
122+
"import": (() => import('shiki/themes/poimandres.json')) as unknown as DynamicThemeReg
123+
},
124+
{
125+
"id": "rose-pine",
126+
"name": "Rose Pine",
127+
"type": "dark",
128+
"import": (() => import('shiki/themes/rose-pine.json')) as unknown as DynamicThemeReg
129+
},
130+
{
131+
"id": "rose-pine-dawn",
132+
"name": "Rose Pine Dawn",
133+
"type": "light",
134+
"import": (() => import('shiki/themes/rose-pine-dawn.json')) as unknown as DynamicThemeReg
135+
},
136+
{
137+
"id": "rose-pine-moon",
138+
"name": "Rose Pine Moon",
139+
"type": "dark",
140+
"import": (() => import('shiki/themes/rose-pine-moon.json')) as unknown as DynamicThemeReg
141+
},
142+
{
143+
"id": "slack-dark",
144+
"name": "Slack Dark",
145+
"type": "dark",
146+
"import": (() => import('shiki/themes/slack-dark.json')) as unknown as DynamicThemeReg
147+
},
148+
{
149+
"id": "slack-ochin",
150+
"name": "Slack Ochin",
151+
"type": "dark",
152+
"import": (() => import('shiki/themes/slack-ochin.json')) as unknown as DynamicThemeReg
153+
},
154+
{
155+
"id": "solarized-dark",
156+
"name": "Solarized Dark",
157+
"type": "dark",
158+
"import": (() => import('shiki/themes/solarized-dark.json')) as unknown as DynamicThemeReg
159+
},
160+
{
161+
"id": "solarized-light",
162+
"name": "Solarized Light",
163+
"type": "light",
164+
"import": (() => import('shiki/themes/solarized-light.json')) as unknown as DynamicThemeReg
165+
},
166+
{
167+
"id": "vitesse-black",
168+
"name": "Vitesse Black",
169+
"type": "dark",
170+
"import": (() => import('shiki/themes/vitesse-black.json')) as unknown as DynamicThemeReg
171+
},
172+
{
173+
"id": "vitesse-dark",
174+
"name": "Vitesse Dark",
175+
"type": "dark",
176+
"import": (() => import('shiki/themes/vitesse-dark.json')) as unknown as DynamicThemeReg
177+
},
178+
{
179+
"id": "vitesse-light",
180+
"name": "Vitesse Light",
181+
"type": "light",
182+
"import": (() => import('shiki/themes/vitesse-light.json')) as unknown as DynamicThemeReg
183+
}
184+
]
185+
186+
export type BuiltinTheme = 'dark-plus' | 'dracula' | 'dracula-soft' | 'github-dark' | 'github-dark-dimmed' | 'github-light' | 'light-plus' | 'material-theme' | 'material-theme-darker' | 'material-theme-lighter' | 'material-theme-ocean' | 'material-theme-palenight' | 'min-dark' | 'min-light' | 'monokai' | 'nord' | 'one-dark-pro' | 'poimandres' | 'rose-pine' | 'rose-pine-dawn' | 'rose-pine-moon' | 'slack-dark' | 'slack-ochin' | 'solarized-dark' | 'solarized-light' | 'vitesse-black' | 'vitesse-dark' | 'vitesse-light'
187+
188+
export const bundledThemes = Object.fromEntries(bundledThemesInfo.map(i => [i.id, i.import])) as Record<BuiltinTheme, DynamicThemeReg>

‎packages/shikiji/src/types.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type { bundledLanguages } from './assets/langs'
2-
import type { bundledThemes } from './themes'
3-
4-
export type BuiltinLanguage = keyof typeof bundledLanguages
5-
export type BuiltinTheme = keyof typeof bundledThemes
1+
export type { BuiltinLanguage, BundledLanguageInfo } from './langs'
2+
export type { BuiltinTheme, BundledThemeInfo } from './themes'
63

74
export type * from 'shikiji-core/types'

‎pnpm-lock.yaml

+197-157
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎taze.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { defineConfig } from 'taze'
22

33
export default defineConfig({
4+
ignorePaths: [
5+
'**/vendor/**',
6+
'**/node_modules/**',
7+
],
48
packageMode: {
59
// The WASM in v2.0 is not compatible with our loader
610
// As there seems to be no much improvement, I guess we could stick with the old version for a while longer

‎tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"shikiji-twoslash": ["./packages/shikiji-twoslash/src/index.ts"],
1414
"shikiji/core": ["./packages/shikiji/src/core.ts"],
1515
"shikiji": ["./packages/shikiji/src/index.ts"],
16+
"shikiji/langs": ["./packages/shikiji/src/langs.ts"],
17+
"shikiji/themes": ["./packages/shikiji/src/themes.ts"],
1618
"markdown-it-shikiji": ["./packages/markdown-it-shikiji/src/index.ts"]
1719
},
1820
"resolveJsonModule": true,

0 commit comments

Comments
 (0)
This repository has been archived.