Nothing; the toolbar icon is updated as a side effect.
// In the app entry point (main.tsx):
initThemeAwareToolbarIcon();
export function initThemeAwareToolbarIcon(): void {
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
return;
}
if (typeof chrome === 'undefined' || chrome.action?.setIcon === undefined) {
return;
}
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
void applyToolbarIcon(darkScheme.matches ? 'dark' : 'light');
darkScheme.addEventListener('change', (event) => {
void applyToolbarIcon(event.matches ? 'dark' : 'light');
});
}
Initializes the theme-aware toolbar icon: applies the icon matching the current
prefers-color-schemeand updates it whenever the scheme changes.Safe to call unconditionally at startup — it no-ops in any context lacking
matchMediaorchrome.action.setIcon(tests, the Vite dev preview, a service worker, or a browser that exposes neither), so it never throws.