30 lines
841 B
TypeScript
30 lines
841 B
TypeScript
const requiredRootTokens = [
|
|
"--theme-version",
|
|
"--is-dark-theme",
|
|
"--color-primary",
|
|
"--color-body",
|
|
"--color-text",
|
|
"--color-input-background",
|
|
"--color-light-border",
|
|
"--border-radius",
|
|
"--github-bgColor-accent-emphasis",
|
|
"--color-syntax-keyword",
|
|
"--color-syntax-string",
|
|
"--color-syntax-comment",
|
|
"--color-syntax-number",
|
|
"--color-syntax-invalid",
|
|
"--color-nav-hoverBg",
|
|
"--color-label-hoverBg",
|
|
"--color-reaction-hoverBg",
|
|
"--color-workflowEdgeHover",
|
|
];
|
|
|
|
export function validateRequiredTokens(rootTokens: string): void {
|
|
const available = new Set(rootTokens.match(/--[A-Za-z0-9_-]+(?=\s*:)/g) ?? []);
|
|
const missing = requiredRootTokens.filter((token) => !available.has(token));
|
|
|
|
if (missing.length > 0) {
|
|
throw new Error(`theme is missing required tokens: ${missing.join(", ")}`);
|
|
}
|
|
}
|