2026-06-15 18:17:38 +03:00
|
|
|
import { registerCustomTheme, type ThemeRegistrationResolved } from '@pierre/diffs';
|
2026-06-15 23:06:54 +03:00
|
|
|
import { MARKDOWN_SHIKI_THEME, MARKDOWN_SHIKI_THEME_DEFINITION } from './markdownShikiThemeDefinition';
|
2026-06-15 18:17:38 +03:00
|
|
|
|
2026-06-15 23:06:54 +03:00
|
|
|
// The static Shiki theme name. Its definition (token colors referencing
|
|
|
|
|
// `--md-syntax-*` CSS variables) lives in the dependency-free
|
|
|
|
|
// `markdownShikiThemeDefinition` module so it can also be imported inside the
|
|
|
|
|
// Shiki Web Worker. See that module for the rationale.
|
2026-06-26 19:27:53 +03:00
|
|
|
|
2026-06-15 18:17:38 +03:00
|
|
|
|
|
|
|
|
let registered = false;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-15 23:06:54 +03:00
|
|
|
* Register the static, CSS-variable-driven Shiki theme with `@pierre/diffs`.
|
|
|
|
|
* Safe to call multiple times; only the first call registers.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: markdown code highlighting now runs through the dedicated Shiki worker
|
|
|
|
|
* (`markdown-worker`), which uses the raw theme definition directly. This
|
|
|
|
|
* registration remains only for any `@pierre/diffs`-based consumer of the
|
|
|
|
|
* `openchamber-md` theme name.
|
2026-06-15 18:17:38 +03:00
|
|
|
*/
|
|
|
|
|
export const ensureMarkdownShikiTheme = (): void => {
|
|
|
|
|
if (registered) return;
|
|
|
|
|
registered = true;
|
|
|
|
|
|
|
|
|
|
registerCustomTheme(MARKDOWN_SHIKI_THEME, () =>
|
2026-06-15 23:06:54 +03:00
|
|
|
Promise.resolve(MARKDOWN_SHIKI_THEME_DEFINITION as unknown as ThemeRegistrationResolved),
|
2026-06-15 18:17:38 +03:00
|
|
|
);
|
|
|
|
|
};
|