/**
* Iconify/sky-icon helpers: extract icon names from code and fetch icon data for offline use.
*
* Usage (browser or Node):
* import { extractIconNames, fetchIconsForOffline, registerOfflineIcons } from '~/components/helper/iconify-offline';
* import { SkyIcon } from '~/components/sky-icon/sky-icon';
*
* // Extract icon names from a code page string
* const names = extractIconNames(''); // ['ion:home']
*
* // Fetch and then register in SkyIcon (directly pass generated JSON)
* const combined = await fetchIconsForOffline(['ion:home', 'mdi:bell']);
* registerOfflineIcons(combined, (prefix, data) => SkyIcon.registerLocalSet(prefix, data));
*
* // Or from saved JSON string:
* const combined = JSON.parse(savedJson);
* registerOfflineIcons(combined, (prefix, data) => SkyIcon.registerLocalSet(prefix, data));
*/
export interface IconifyIconData {
body?: string;
left?: number;
top?: number;
width?: number;
height?: number;
viewBox?: string;
hidden?: boolean;
}
export interface IconifySetData {
prefix?: string;
icons: Record;
width?: number;
height?: number;
left?: number;
top?: number;
/** Icon names requested but not in API response; add manually if needed. Omit when registering with SkyIcon. */
_notFound?: string[];
}
/** Combined offline data: prefix -> Iconify set data (ready for SkyIcon.registerLocalSet). Skip keys starting with _ when registering. */
export type CombinedOfflineIcons = Record;
export interface FetchIconsForOfflineOptions {
/** Iconify API base URL (default: https://api.iconify.design) */
baseUrl?: string;
}
/**
* Extracts all icon names in "prefix:icon-name" format from a code page string.
* Looks for icon names inside single, double, or backtick quotes (e.g. in attributes
* like icon="ion:home", iconL='mdi:bell', or :icon="`ion:person`").
*
* @param codePageString - Source code string (HTML, Vue, TS, JS, etc.)
* @returns Array of unique icon names (e.g. ["ion:home", "mdi:bell"])
*/
export declare function extractIconNames(codePageString: string): string[];
/**
* Fetches icon data from the Iconify API for the given icon names, groups by prefix,
* and returns a combined JSON object keyed by prefix for offline use.
*
* @param iconNames - List of icon names in "prefix:icon-name" format (e.g. ["ion:home", "mdi:bell"])
* @param options - Optional baseUrl for the Iconify API
* @returns Combined object: { "ion": { prefix, icons, width, height }, "mdi": { ... }, ... }
* Use with SkyIcon.registerLocalSet(prefix, combined[prefix]) for each prefix.
*/
export declare function fetchIconsForOffline(iconNames: string[], options?: FetchIconsForOfflineOptions): Promise;
/** Set data without _notFound / _comment (suitable for SkyIcon.registerLocalSet). */
type SetDataForRegister = Omit;
/**
* Registers the generated offline JSON with SkyIcon. Pass the object returned by fetchIconsForOffline
* (or parsed from saved JSON). Skips top-level keys starting with "_" and strips _notFound from each set.
*
* @param combined - The combined object (from fetchIconsForOffline or JSON.parse of saved output)
* @param register - Callback to register each set, e.g. (prefix, data) => SkyIcon.registerLocalSet(prefix, data)
*/
export declare function registerOfflineIcons(combined: CombinedOfflineIcons & Record, register: (prefix: string, data: SetDataForRegister) => void): void;
export {};