iconly
Version:
Iconly is designed to load and cache SVG icons in the browser, using IndexedDB to store the data. It retrieves the icons from a given SVG file, stores them in IndexedDB, and inserts them into the DOM for easy access and use.
56 lines (45 loc) • 1.56 kB
TypeScript
export declare const createIconly: (config?: IconlyConfig) => IconlyInstance;
export declare interface IconlyConfig {
file?: string;
version?: string;
debug?: boolean;
container?: string | HTMLElement;
storage?: StorageStrategy;
dbName?: string;
storeName?: string;
sessionKeyPrefix?: string;
logger?: Logger;
onError?: (error: IconlyError) => void;
onDebug?: (...messages: unknown[]) => void;
}
export declare interface IconlyError {
code: IconlyErrorCode;
message: string;
cause?: unknown;
}
export declare type IconlyErrorCode = 'container_invalid' | 'fetch_aborted' | 'fetch_failed' | 'indexeddb_not_supported' | 'indexeddb_open_failed' | 'indexeddb_request_failed' | 'parse_error' | 'storage_read_failed' | 'storage_unavailable' | 'storage_write_failed';
export declare interface IconlyInstance {
init: () => Promise<Result<void>>;
abort: () => void;
}
export declare interface IconRecord {
version: string;
data: string;
}
export declare interface IconStorage {
get(version: string): Promise<Result<IconRecord | undefined>>;
set(record: IconRecord): Promise<Result<void>>;
}
export declare interface Logger {
debug?: (...messages: unknown[]) => void;
error?: (...messages: unknown[]) => void;
}
export declare type Result<T> = {
ok: true;
value: T;
} | {
ok: false;
error: IconlyError;
};
export declare type StorageStrategy = 'indexeddb' | 'memory' | 'session' | IconStorage;
export { }