mirror of
https://github.com/iconify/iconify.git
synced 2025-01-07 15:44:05 +00:00
Clean up code for IconifyPreload and IconifyProviders
This commit is contained in:
parent
3f6265fdac
commit
7214c077b4
@ -211,18 +211,14 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
// addFinder(iconifyIconFinder);
|
// addFinder(iconifyIconFinder);
|
||||||
addFinder(iconifyFinder);
|
addFinder(iconifyFinder);
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyPreload?: IconifyJSON[] | IconifyJSON;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Load icons from global "IconifyPreload"
|
// Load icons from global "IconifyPreload"
|
||||||
interface WindowWithIconifyPreload {
|
if (_window.IconifyPreload !== void 0) {
|
||||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
const preload = _window.IconifyPreload;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyPreload).IconifyPreload !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const preload = (_window as unknown as WindowWithIconifyPreload)
|
|
||||||
.IconifyPreload;
|
|
||||||
const err = 'Invalid IconifyPreload syntax.';
|
const err = 'Invalid IconifyPreload syntax.';
|
||||||
if (typeof preload === 'object' && preload !== null) {
|
if (typeof preload === 'object' && preload !== null) {
|
||||||
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
||||||
|
@ -130,10 +130,10 @@ const browserCacheFunctions: IconifyBrowserCacheFunctions = {
|
|||||||
/**
|
/**
|
||||||
* Global variable
|
* Global variable
|
||||||
*/
|
*/
|
||||||
const Iconify = ({
|
const Iconify = {
|
||||||
// Exposed internal API functions
|
// Exposed internal API functions
|
||||||
_api: APIInternalFunctions,
|
_api: APIInternalFunctions,
|
||||||
} as unknown) as IconifyGlobal;
|
} as unknown as IconifyGlobal;
|
||||||
|
|
||||||
// Add functions
|
// Add functions
|
||||||
[
|
[
|
||||||
@ -188,18 +188,14 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
coreModules.cache = storeCache;
|
coreModules.cache = storeCache;
|
||||||
loadCache();
|
loadCache();
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyProviders?: Record<string, PartialIconifyAPIConfig>;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Set API from global "IconifyProviders"
|
// Set API from global "IconifyProviders"
|
||||||
interface WindowWithIconifyProviders {
|
if (_window.IconifyProviders !== void 0) {
|
||||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
const providers = _window.IconifyProviders;
|
||||||
}
|
|
||||||
if (
|
|
||||||
((_window as unknown) as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders !== void 0
|
|
||||||
) {
|
|
||||||
const providers = ((_window as unknown) as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders;
|
|
||||||
if (typeof providers === 'object' && providers !== null) {
|
if (typeof providers === 'object' && providers !== null) {
|
||||||
for (let key in providers) {
|
for (let key in providers) {
|
||||||
const err = 'IconifyProviders[' + key + '] is invalid.';
|
const err = 'IconifyProviders[' + key + '] is invalid.';
|
||||||
|
@ -233,18 +233,15 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
coreModules.cache = storeCache;
|
coreModules.cache = storeCache;
|
||||||
loadCache();
|
loadCache();
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyPreload?: IconifyJSON[] | IconifyJSON;
|
||||||
|
IconifyProviders?: Record<string, PartialIconifyAPIConfig>;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Load icons from global "IconifyPreload"
|
// Load icons from global "IconifyPreload"
|
||||||
interface WindowWithIconifyPreload {
|
if (_window.IconifyPreload !== void 0) {
|
||||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
const preload = _window.IconifyPreload;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyPreload).IconifyPreload !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const preload = (_window as unknown as WindowWithIconifyPreload)
|
|
||||||
.IconifyPreload;
|
|
||||||
const err = 'Invalid IconifyPreload syntax.';
|
const err = 'Invalid IconifyPreload syntax.';
|
||||||
if (typeof preload === 'object' && preload !== null) {
|
if (typeof preload === 'object' && preload !== null) {
|
||||||
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
||||||
@ -270,15 +267,8 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set API from global "IconifyProviders"
|
// Set API from global "IconifyProviders"
|
||||||
interface WindowWithIconifyProviders {
|
if (_window.IconifyProviders !== void 0) {
|
||||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
const providers = _window.IconifyProviders;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyProviders).IconifyProviders !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const providers = (_window as unknown as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders;
|
|
||||||
if (typeof providers === 'object' && providers !== null) {
|
if (typeof providers === 'object' && providers !== null) {
|
||||||
for (let key in providers) {
|
for (let key in providers) {
|
||||||
const err = 'IconifyProviders[' + key + '] is invalid.';
|
const err = 'IconifyProviders[' + key + '] is invalid.';
|
||||||
|
@ -229,18 +229,15 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
coreModules.cache = storeCache;
|
coreModules.cache = storeCache;
|
||||||
loadCache();
|
loadCache();
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyPreload?: IconifyJSON[] | IconifyJSON;
|
||||||
|
IconifyProviders?: Record<string, PartialIconifyAPIConfig>;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Load icons from global "IconifyPreload"
|
// Load icons from global "IconifyPreload"
|
||||||
interface WindowWithIconifyPreload {
|
if (_window.IconifyPreload !== void 0) {
|
||||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
const preload = _window.IconifyPreload;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyPreload).IconifyPreload !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const preload = (_window as unknown as WindowWithIconifyPreload)
|
|
||||||
.IconifyPreload;
|
|
||||||
const err = 'Invalid IconifyPreload syntax.';
|
const err = 'Invalid IconifyPreload syntax.';
|
||||||
if (typeof preload === 'object' && preload !== null) {
|
if (typeof preload === 'object' && preload !== null) {
|
||||||
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
||||||
@ -266,15 +263,8 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set API from global "IconifyProviders"
|
// Set API from global "IconifyProviders"
|
||||||
interface WindowWithIconifyProviders {
|
if (_window.IconifyProviders !== void 0) {
|
||||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
const providers = _window.IconifyProviders;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyProviders).IconifyProviders !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const providers = (_window as unknown as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders;
|
|
||||||
if (typeof providers === 'object' && providers !== null) {
|
if (typeof providers === 'object' && providers !== null) {
|
||||||
for (let key in providers) {
|
for (let key in providers) {
|
||||||
const err = 'IconifyProviders[' + key + '] is invalid.';
|
const err = 'IconifyProviders[' + key + '] is invalid.';
|
||||||
|
@ -241,18 +241,15 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
coreModules.cache = storeCache;
|
coreModules.cache = storeCache;
|
||||||
loadCache();
|
loadCache();
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyPreload?: IconifyJSON[] | IconifyJSON;
|
||||||
|
IconifyProviders?: Record<string, PartialIconifyAPIConfig>;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Load icons from global "IconifyPreload"
|
// Load icons from global "IconifyPreload"
|
||||||
interface WindowWithIconifyPreload {
|
if (_window.IconifyPreload !== void 0) {
|
||||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
const preload = _window.IconifyPreload;
|
||||||
}
|
|
||||||
if (
|
|
||||||
((_window as unknown) as WindowWithIconifyPreload).IconifyPreload !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const preload = ((_window as unknown) as WindowWithIconifyPreload)
|
|
||||||
.IconifyPreload;
|
|
||||||
const err = 'Invalid IconifyPreload syntax.';
|
const err = 'Invalid IconifyPreload syntax.';
|
||||||
if (typeof preload === 'object' && preload !== null) {
|
if (typeof preload === 'object' && preload !== null) {
|
||||||
(preload instanceof Array ? preload : [preload]).forEach(item => {
|
(preload instanceof Array ? preload : [preload]).forEach(item => {
|
||||||
@ -278,15 +275,8 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set API from global "IconifyProviders"
|
// Set API from global "IconifyProviders"
|
||||||
interface WindowWithIconifyProviders {
|
if (_window.IconifyProviders !== void 0) {
|
||||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
const providers = _window.IconifyProviders;
|
||||||
}
|
|
||||||
if (
|
|
||||||
((_window as unknown) as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders !== void 0
|
|
||||||
) {
|
|
||||||
const providers = ((_window as unknown) as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders;
|
|
||||||
if (typeof providers === 'object' && providers !== null) {
|
if (typeof providers === 'object' && providers !== null) {
|
||||||
for (let key in providers) {
|
for (let key in providers) {
|
||||||
const err = 'IconifyProviders[' + key + '] is invalid.';
|
const err = 'IconifyProviders[' + key + '] is invalid.';
|
||||||
|
@ -233,18 +233,15 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
coreModules.cache = storeCache;
|
coreModules.cache = storeCache;
|
||||||
loadCache();
|
loadCache();
|
||||||
|
|
||||||
const _window = window;
|
interface WindowWithIconifyStuff {
|
||||||
|
IconifyPreload?: IconifyJSON[] | IconifyJSON;
|
||||||
|
IconifyProviders?: Record<string, PartialIconifyAPIConfig>;
|
||||||
|
}
|
||||||
|
const _window = window as WindowWithIconifyStuff;
|
||||||
|
|
||||||
// Load icons from global "IconifyPreload"
|
// Load icons from global "IconifyPreload"
|
||||||
interface WindowWithIconifyPreload {
|
if (_window.IconifyPreload !== void 0) {
|
||||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
const preload = _window.IconifyPreload;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyPreload).IconifyPreload !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const preload = (_window as unknown as WindowWithIconifyPreload)
|
|
||||||
.IconifyPreload;
|
|
||||||
const err = 'Invalid IconifyPreload syntax.';
|
const err = 'Invalid IconifyPreload syntax.';
|
||||||
if (typeof preload === 'object' && preload !== null) {
|
if (typeof preload === 'object' && preload !== null) {
|
||||||
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
||||||
@ -270,15 +267,8 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set API from global "IconifyProviders"
|
// Set API from global "IconifyProviders"
|
||||||
interface WindowWithIconifyProviders {
|
if (_window.IconifyProviders !== void 0) {
|
||||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
const providers = _window.IconifyProviders;
|
||||||
}
|
|
||||||
if (
|
|
||||||
(_window as unknown as WindowWithIconifyProviders).IconifyProviders !==
|
|
||||||
void 0
|
|
||||||
) {
|
|
||||||
const providers = (_window as unknown as WindowWithIconifyProviders)
|
|
||||||
.IconifyProviders;
|
|
||||||
if (typeof providers === 'object' && providers !== null) {
|
if (typeof providers === 'object' && providers !== null) {
|
||||||
for (let key in providers) {
|
for (let key in providers) {
|
||||||
const err = 'IconifyProviders[' + key + '] is invalid.';
|
const err = 'IconifyProviders[' + key + '] is invalid.';
|
||||||
|
Loading…
Reference in New Issue
Block a user