/** * Theme loading utilities for Script Kit. * Provides shared logic for loading and building theme choices, * eliminating duplication between theme-selector.ts and new-theme.ts. */ import type { ThemePaths, ThemeChoice, ThemeGroup } from '../types/theme.js'; /** * Load theme file paths from the filesystem. * Searches kenv/themes for custom themes and kit/themes for built-in themes. * * @param kenvPath - Function to resolve kenv paths * @param kitPath - Function to resolve kit paths * @returns Object containing arrays of custom, built-in, and default theme paths * * @example * ```ts * const paths = await loadThemePaths(kenvPath, kitPath) * console.log(paths.custom) // ['/Users/.../kenv/themes/my-theme.css'] * console.log(paths.defaults) // ['/Users/.../kit/themes/script-kit-dark.css'] * ``` */ export declare function loadThemePaths(kenvPath: (...args: string[]) => string, kitPath: (...args: string[]) => string): Promise; /** * Options for building theme choices. */ export interface BuildThemeChoicesOptions { /** Theme paths from loadThemePaths */ paths: ThemePaths; /** Function to read file contents */ readFile: (path: string, encoding: 'utf-8') => Promise; /** Node.js path module */ pathModule: { basename: (p: string) => string; }; /** Function to set theme preview */ setScriptTheme: (css: string) => void; /** Markdown renderer */ md: (content: string) => string; /** Preview content (e.g., guide markdown) */ previewContent: string; /** Order of groups in the final list */ groupOrder?: ThemeGroup[]; } /** * Build theme choices from loaded paths. * Creates choice objects suitable for the arg() selector. * * @param options - Configuration for building choices * @returns Array of theme choices grouped by category * * @example * ```ts * const paths = await loadThemePaths(kenvPath, kitPath) * const guide = await readFile(kitPath('GUIDE.md'), 'utf-8') * * const choices = await buildThemeChoices({ * paths, * readFile, * pathModule: path, * setScriptTheme, * md, * previewContent: guide, * }) * ``` */ export declare function buildThemeChoices(options: BuildThemeChoicesOptions): Promise; /** * Extract the theme name from CSS content. * * @param css - Raw CSS string * @returns Theme name or undefined if not found * * @example * ```ts * const css = ':root { --name: "My Theme"; }' * const name = extractThemeName(css) // "My Theme" * ``` */ export declare function extractThemeName(css: string): string | undefined; /** * Replace the theme name in CSS content. * * @param css - Raw CSS string * @param newName - New theme name * @returns Updated CSS string * * @example * ```ts * const css = ':root { --name: "Old Name"; }' * const updated = replaceThemeName(css, "New Name") * // ':root { --name: "New Name"; }' * ``` */ export declare function replaceThemeName(css: string, newName: string): string; /** * Convert a theme name to a valid filename slug. * * @param name - Theme display name * @returns Lowercase, hyphenated filename (without extension) * * @example * ```ts * slugifyThemeName("My Cool Theme!") // "my-cool-theme-" * slugifyThemeName("Dark Mode v2") // "dark-mode-v2" * ``` */ export declare function slugifyThemeName(name: string): string;