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,
|
||||
allowSimpleNames,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -228,7 +228,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
getIconData,
|
||||
allowSimpleNames,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -464,7 +464,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -8,7 +8,6 @@ import {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
@ -26,7 +25,6 @@ export {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
getIconData,
|
||||
allowSimpleNames,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -358,7 +358,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -55,7 +55,6 @@ export {
|
||||
listIcons,
|
||||
addIcon,
|
||||
addCollection,
|
||||
shareStorage,
|
||||
} from './functions';
|
||||
|
||||
export { calculateSize, replaceIDs, buildIcon } from './functions';
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
addIcon,
|
||||
addCollection,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -213,7 +213,6 @@ const Iconify: IconifyGlobal = {
|
||||
listIcons,
|
||||
addIcon,
|
||||
addCollection,
|
||||
shareStorage,
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
replaceIDs,
|
||||
@ -251,7 +250,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
addIcon,
|
||||
addCollection,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -63,7 +63,6 @@ const Iconify: IconifyGlobal = {
|
||||
listIcons,
|
||||
addIcon,
|
||||
addCollection,
|
||||
shareStorage,
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
replaceIDs,
|
||||
@ -91,7 +90,7 @@ export default Iconify;
|
||||
* Named exports
|
||||
*/
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
getIconData,
|
||||
allowSimpleNames,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -404,7 +404,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
getIconData,
|
||||
allowSimpleNames,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
@ -386,7 +386,7 @@ export { _api };
|
||||
export { addAPIProvider, loadIcons, loadIcon };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection, shareStorage };
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
addIcon,
|
||||
addCollection,
|
||||
} 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 { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||
@ -159,7 +159,6 @@ export function exportFunctions(): IconifyExportedFunctions {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
|
@ -112,7 +112,6 @@ const {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
@ -129,7 +128,6 @@ export {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
|
@ -60,7 +60,6 @@ export {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
|
@ -61,7 +61,6 @@ export {
|
||||
iconExists,
|
||||
getIcon,
|
||||
listIcons,
|
||||
shareStorage,
|
||||
addIcon,
|
||||
addCollection,
|
||||
calculateSize,
|
||||
|
@ -35,15 +35,6 @@ export interface IconifyStorageFunctions {
|
||||
* Add icon set to storage
|
||||
*/
|
||||
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>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage format version
|
||||
*/
|
||||
const storageVersion = 1;
|
||||
|
||||
/**
|
||||
* Storage by provider and prefix
|
||||
*/
|
||||
let storage = Object.create(null) as Record<
|
||||
const storage = Object.create(null) as Record<
|
||||
string,
|
||||
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user