rn-shiki 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/index.ts +0 -2
- package/src/langs.ts +0 -20
- package/src/themes.ts +0 -20
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/langs.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { LanguageInput } from 'shiki'
|
2
|
-
import manifest from '../vendor/shiki/manifest.json'
|
3
|
-
|
4
|
-
export type AvailableLanguage = keyof typeof manifest.langs
|
5
|
-
|
6
|
-
export const Languages = Object.keys(manifest.langs).reduce((acc, lang) => {
|
7
|
-
const key = lang.replace(/-/g, '_').toUpperCase()
|
8
|
-
return { ...acc, [key]: lang as AvailableLanguage }
|
9
|
-
}, {} as Record<string, AvailableLanguage>)
|
10
|
-
|
11
|
-
export async function getLanguage(langName: AvailableLanguage): Promise<LanguageInput> {
|
12
|
-
try {
|
13
|
-
const lang = await import(`../vendor/shiki/langs/${String(langName)}.js`)
|
14
|
-
return lang.default
|
15
|
-
}
|
16
|
-
catch (err) {
|
17
|
-
const error = err instanceof Error ? err.message : String(err)
|
18
|
-
throw new Error(`Language '${String(langName)}' failed to load: ${error}`)
|
19
|
-
}
|
20
|
-
}
|
package/src/themes.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { ThemeInput } from 'shiki'
|
2
|
-
import manifest from '../vendor/shiki/manifest.json'
|
3
|
-
|
4
|
-
export type AvailableTheme = keyof typeof manifest.themes
|
5
|
-
|
6
|
-
export const Themes = Object.keys(manifest.themes).reduce<Record<string, AvailableTheme>>((acc, theme) => {
|
7
|
-
const key = (theme as AvailableTheme).replace(/-/g, '_').toUpperCase()
|
8
|
-
return { ...acc, [key]: theme as AvailableTheme }
|
9
|
-
}, {} as Record<string, AvailableTheme>)
|
10
|
-
|
11
|
-
export async function getTheme(themeName: AvailableTheme): Promise<ThemeInput> {
|
12
|
-
try {
|
13
|
-
const theme = await import(`../vendor/shiki/themes/${String(themeName)}.js`)
|
14
|
-
return theme.default
|
15
|
-
}
|
16
|
-
catch (err) {
|
17
|
-
const error = err instanceof Error ? err.message : String(err)
|
18
|
-
throw new Error(`Theme '${String(themeName)}' failed to load: ${error}`)
|
19
|
-
}
|
20
|
-
}
|