mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 14:50:56 +00:00
Remove shareStorage function - no longer needed because web component reuses same class even if bundled multiple times
This commit is contained in:
parent
390fac8759
commit
a64b9a78ff
@ -11,7 +11,7 @@ import {
|
|||||||
addCollection,
|
addCollection,
|
||||||
allowSimpleNames,
|
allowSimpleNames,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -228,7 +228,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
getIconData,
|
getIconData,
|
||||||
allowSimpleNames,
|
allowSimpleNames,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -464,7 +464,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
@ -26,7 +25,6 @@ export {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
getIconData,
|
getIconData,
|
||||||
allowSimpleNames,
|
allowSimpleNames,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -358,7 +358,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -55,7 +55,6 @@ export {
|
|||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
shareStorage,
|
|
||||||
} from './functions';
|
} from './functions';
|
||||||
|
|
||||||
export { calculateSize, replaceIDs, buildIcon } from './functions';
|
export { calculateSize, replaceIDs, buildIcon } from './functions';
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -213,7 +213,6 @@ const Iconify: IconifyGlobal = {
|
|||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
shareStorage,
|
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
replaceIDs,
|
replaceIDs,
|
||||||
@ -251,7 +250,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -63,7 +63,6 @@ const Iconify: IconifyGlobal = {
|
|||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
shareStorage,
|
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
replaceIDs,
|
replaceIDs,
|
||||||
@ -91,7 +90,7 @@ export default Iconify;
|
|||||||
* Named exports
|
* Named exports
|
||||||
*/
|
*/
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
getIconData,
|
getIconData,
|
||||||
allowSimpleNames,
|
allowSimpleNames,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -404,7 +404,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -16,7 +16,7 @@ import {
|
|||||||
getIconData,
|
getIconData,
|
||||||
allowSimpleNames,
|
allowSimpleNames,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
@ -386,7 +386,7 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import { listIcons, shareStorage } from '@iconify/core/lib/storage/storage';
|
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||||
@ -159,7 +159,6 @@ export function exportFunctions(): IconifyExportedFunctions {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
|
@ -112,7 +112,6 @@ const {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
@ -129,7 +128,6 @@ export {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
|
@ -60,7 +60,6 @@ export {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
|
@ -61,7 +61,6 @@ export {
|
|||||||
iconExists,
|
iconExists,
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
shareStorage,
|
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
calculateSize,
|
calculateSize,
|
||||||
|
@ -35,15 +35,6 @@ export interface IconifyStorageFunctions {
|
|||||||
* Add icon set to storage
|
* Add icon set to storage
|
||||||
*/
|
*/
|
||||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* Share storage (used to share icon data between various components or multiple instances of component)
|
|
||||||
*
|
|
||||||
* It works by moving storage to global variable, new instances of component attempt to detect global
|
|
||||||
* variable during load. Therefore, function should be called as soon as possible.
|
|
||||||
* Works only in browser, not usable in SSR.
|
|
||||||
*/
|
|
||||||
shareStorage: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,55 +19,14 @@ export interface IconStorage {
|
|||||||
missing: Record<string, number>;
|
missing: Record<string, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Storage format version
|
|
||||||
*/
|
|
||||||
const storageVersion = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage by provider and prefix
|
* Storage by provider and prefix
|
||||||
*/
|
*/
|
||||||
let storage = Object.create(null) as Record<
|
const storage = Object.create(null) as Record<
|
||||||
string,
|
string,
|
||||||
Record<string, IconStorage>
|
Record<string, IconStorage>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Share storage
|
|
||||||
*/
|
|
||||||
interface WindowWithStorage extends Window {
|
|
||||||
_iconifyStorage: {
|
|
||||||
version: number;
|
|
||||||
storage: Record<string, Record<string, IconStorage>>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const w = (window || self) as unknown as WindowWithStorage | undefined;
|
|
||||||
if (w && w._iconifyStorage.version === storageVersion) {
|
|
||||||
storage = w._iconifyStorage.storage;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Share storage between components
|
|
||||||
*/
|
|
||||||
export function shareStorage(): void {
|
|
||||||
try {
|
|
||||||
const w = (window || self) as unknown as WindowWithStorage | undefined;
|
|
||||||
if (w && !w._iconifyStorage) {
|
|
||||||
w._iconifyStorage = {
|
|
||||||
version: storageVersion,
|
|
||||||
storage,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new storage
|
* Create new storage
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user