ShikiCodeBlocks: Update assets (#3785)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
thororen 2025-12-05 20:33:17 -05:00 committed by GitHub
parent 3ea80c254a
commit 192d6a2237
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 16 deletions

View file

@ -18,11 +18,12 @@
import { ILanguageRegistration } from "@vap/shiki";
export const VPC_REPO = "Vap0r1ze/vapcord";
export const VPC_REPO_COMMIT = "4d0e4b420fb1e4358852bbd18c804a6f5e54c0d7";
export const vpcRepoAssets = `https://raw.githubusercontent.com/${VPC_REPO}/${VPC_REPO_COMMIT}/assets/shiki-codeblocks`;
export const vpcRepoGrammar = (fileName: string) => `${vpcRepoAssets}/${fileName}`;
export const vpcRepoLanguages = `${vpcRepoAssets}/languages.json`;
import { SHIKI_REPO, SHIKI_REPO_COMMIT } from "./themes";
export const JSON_REPO = "Vencord/ShikiPluginAssets";
export const JSON_REPO_COMMIT = "75d69df9fdf596a31eef8b7f6f891231a6feab44";
export const JSON_URL = `https://cdn.jsdelivr.net/gh/${JSON_REPO}@${JSON_REPO_COMMIT}/grammars.json`;
export const shikiRepoGrammar = (name: string) => `https://cdn.jsdelivr.net/gh/${SHIKI_REPO}@${SHIKI_REPO_COMMIT}/packages/tm-grammars/grammars/${name}.json`;
export interface Language {
name: string;
@ -36,22 +37,26 @@ export interface Language {
}
export interface LanguageJson {
name: string;
id: string;
fileName: string;
devicon?: string;
displayName: string;
scopeName: string;
devicon?: string;
aliases?: string[];
}
export const languages: Record<string, Language> = {};
export const loadLanguages = async () => {
const langsJson: LanguageJson[] = await fetch(vpcRepoLanguages).then(res => res.ok ? res.json() : []);
const langsJson: LanguageJson[] = await fetch(JSON_URL).then(res => res.ok ? res.json() : []);
const loadedLanguages = Object.fromEntries(
langsJson.map(lang => [lang.id, {
...lang,
grammarUrl: vpcRepoGrammar(lang.fileName),
}])
langsJson.map(lang => {
const { name, displayName, ...rest } = lang;
return [name, {
...rest,
id: name,
name: displayName,
grammarUrl: shikiRepoGrammar(name),
}];
})
);
Object.assign(languages, loadedLanguages);
};

View file

@ -19,8 +19,8 @@
import { IShikiTheme } from "@vap/shiki";
export const SHIKI_REPO = "shikijs/textmate-grammars-themes";
export const SHIKI_REPO_COMMIT = "2d87559c7601a928b9f7e0f0dda243d2fb6d4499";
export const shikiRepoTheme = (name: string) => `https://raw.githubusercontent.com/${SHIKI_REPO}/${SHIKI_REPO_COMMIT}/packages/tm-themes/themes/${name}.json`;
export const SHIKI_REPO_COMMIT = "bc5436518111d87ea58eb56d97b3f9bec30e6b83";
export const shikiRepoTheme = (name: string) => `https://cdn.jsdelivr.net/gh/${SHIKI_REPO}@${SHIKI_REPO_COMMIT}/packages/tm-themes/themes/${name}.json`;
export const themes = {
// Default
@ -48,6 +48,12 @@ export const themes = {
GithubLightDefault: shikiRepoTheme("github-light-default"),
GithubLightHighContrast: shikiRepoTheme("github-light-high-contrast"),
GithubLight: shikiRepoTheme("github-light"),
GruvBoxDarkHard: shikiRepoTheme("gruvbox-dark-hard"),
GruvBoxDarkMedium: shikiRepoTheme("gruvbox-dark-medium"),
GruvBoxDarkSoft: shikiRepoTheme("gruvbox-dark-soft"),
GruvBoxLightHard: shikiRepoTheme("gruvbox-light-hard"),
GruvBoxLightMedium: shikiRepoTheme("gruvbox-light-medium"),
GruvBoxLightSoft: shikiRepoTheme("gruvbox-light-soft"),
Houston: shikiRepoTheme("houston"),
KanagawaDragon: shikiRepoTheme("kanagawa-dragon"),
KanagawaLotus: shikiRepoTheme("kanagawa-lotus"),

View file

@ -1 +1 @@
@import url("https://cdn.jsdelivr.net/gh/devicons/devicon@v2.10.1/devicon.min.css");
@import url("https://cdn.jsdelivr.net/gh/devicons/devicon@v2.17.0/devicon.min.css");