/** * Pre-paint theme bootstrap script generator. * * ThemeProvider resolves the persisted/system color scheme only after mount, * so apps without a pre-paint script flash the wrong scheme on load. Apps used * to hand-duplicate the provider's storage logic in `app.html`; this helper * generates that script from the same config so the two never drift. * * The script only stamps attributes (`data-theme`, `data-color-scheme`, the * `dark` class, `color-scheme` style) — the actual variable values come from * the static per-preset stylesheets (`themes/styles/.css`), which are * keyed on exactly those attributes and apply before first paint. This keeps * the inline bootstrap ~400 bytes instead of shipping a full preset×scheme * variable matrix in every HTML response. * * Usage (root layout — SSR renders `svelte:head` into the initial HTML, so the * script runs before first paint): * * ```svelte * * * * {@html ``} * * ``` */ import type { ColorScheme, ThemePreset } from './types.js'; export interface ThemeScriptOptions { /** Preset to stamp as `data-theme` when nothing is persisted. */ preset?: ThemePreset; /** Read persisted preferences. Must match ThemeProvider's `persist` prop. */ persist?: boolean; /** localStorage key — must match ThemeProvider's `storageKey`. */ storageKey?: string; /** Fallback scheme when storage holds no value. Default: 'system'. */ defaultColorScheme?: ColorScheme; } /** * Returns the JS body (no `