diff --git a/package.json b/package.json index 7acd2e3..6495034 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Iconify API", "author": "Vjacheslav Trushkin", "license": "MIT", - "version": "3.1.0-beta.1", + "version": "3.1.0-beta.2", "publishConfig": { "access": "public", "tag": "next" diff --git a/src/data/loading.ts b/src/data/loading.ts index c8c0e3d..8cc7eac 100644 --- a/src/data/loading.ts +++ b/src/data/loading.ts @@ -22,6 +22,13 @@ export function loaded() { } } +/** + * Get state + */ +export function isLoading() { + return loading; +} + /** * Run when app is ready */ diff --git a/src/init.ts b/src/init.ts index 850a6ed..db4e83e 100644 --- a/src/init.ts +++ b/src/init.ts @@ -2,19 +2,35 @@ import { getImporters } from './config/icon-sets.js'; import { iconSetsStorage } from './data/icon-set/store/storage.js'; import { setImporters, updateIconSets } from './data/icon-sets.js'; import { cleanupStorageCache } from './data/storage/startup.js'; +import { Importer } from './types/importers.js'; + +interface InitOptions { + // Cleanup storage cache + cleanup?: boolean; + + // Importers + importers?: Importer[]; +} /** * Init API */ -export async function initAPI() { +export async function initAPI(options: InitOptions = {}) { // Reset old cache - await cleanupStorageCache(iconSetsStorage); + if (options.cleanup !== false) { + await cleanupStorageCache(iconSetsStorage); + } // Get all importers and load data - const importers = await getImporters(); - for (let i = 0; i < importers.length; i++) { - await importers[i].init(); + let importers = options.importers; + if (!importers) { + importers = await getImporters(); + for (let i = 0; i < importers.length; i++) { + await importers[i].init(); + } } + + // Update setImporters(importers); updateIconSets(); }