Skip to content

Commit 2686332

Browse files
committed
chore: add iconify-icon 3.0.2
1 parent e109c0d commit 2686332

File tree

10 files changed

+7387
-135
lines changed

10 files changed

+7387
-135
lines changed

iconify-icon/3-latest/iconify-icon.cjs

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,29 @@
77
* Licensed under MIT.
88
*
99
* @license MIT
10-
* @version 3.0.1
10+
* @version 3.0.2
1111
*/
1212
'use strict';
1313

14-
/**
15-
* Default values for dimensions
16-
*/
14+
/** Default values for dimensions */
1715
const defaultIconDimensions = Object.freeze({
1816
left: 0,
1917
top: 0,
2018
width: 16,
2119
height: 16
2220
});
23-
/**
24-
* Default values for transformations
25-
*/
21+
/** Default values for transformations */
2622
const defaultIconTransformations = Object.freeze({
2723
rotate: 0,
2824
vFlip: false,
2925
hFlip: false
3026
});
31-
/**
32-
* Default values for all optional IconifyIcon properties
33-
*/
27+
/** Default values for all optional IconifyIcon properties */
3428
const defaultIconProps = Object.freeze({
3529
...defaultIconDimensions,
3630
...defaultIconTransformations
3731
});
38-
/**
39-
* Default values for all properties used in ExtendedIconifyIcon
40-
*/
32+
/** Default values for all properties used in ExtendedIconifyIcon */
4133
const defaultExtendedIconProps = Object.freeze({
4234
...defaultIconProps,
4335
body: "",
@@ -92,8 +84,7 @@ const separator = /[\s,]+/;
9284
*/
9385
function flipFromString(custom, flip) {
9486
flip.split(separator).forEach((str) => {
95-
const value = str.trim();
96-
switch (value) {
87+
switch (str.trim()) {
9788
case "horizontal":
9889
custom.hFlip = true;
9990
break;
@@ -375,10 +366,8 @@ function addIconToStorage(storage, name, icon) {
375366
*/
376367
function listIcons$1(provider, prefix) {
377368
let allIcons = [];
378-
const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
379-
providers.forEach((provider$1) => {
380-
const prefixes = typeof provider$1 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider$1] || {});
381-
prefixes.forEach((prefix$1) => {
369+
(typeof provider === "string" ? [provider] : Object.keys(dataStorage)).forEach((provider$1) => {
370+
(typeof provider$1 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider$1] || {})).forEach((prefix$1) => {
382371
const storage = getStorage(provider$1, prefix$1);
383372
allIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider$1 !== "" ? "@" + provider$1 + ":" : "") + prefix$1 + ":" + name));
384373
});
@@ -444,8 +433,7 @@ function addCollection$1(data, provider) {
444433
prefix,
445434
name: "a"
446435
})) return false;
447-
const storage = getStorage(provider, prefix);
448-
return !!addIconSet(storage, data);
436+
return !!addIconSet(getStorage(provider, prefix), data);
449437
}
450438
/**
451439
* Check if icon data is available
@@ -620,7 +608,7 @@ function createAPIConfig(source) {
620608
resources = source.resources;
621609
if (!(resources instanceof Array) || !resources.length) return null;
622610
}
623-
const result = {
611+
return {
624612
resources,
625613
path: source.path || "/",
626614
maxURL: source.maxURL || 500,
@@ -630,7 +618,6 @@ function createAPIConfig(source) {
630618
index: source.index || 0,
631619
dataAfterTimeout: source.dataAfterTimeout !== false
632620
};
633-
return result;
634621
}
635622
/**
636623
* Local storage
@@ -882,7 +869,7 @@ function initRedundancy(cfg) {
882869
return callback(value);
883870
}) || null;
884871
}
885-
const instance = {
872+
return {
886873
query,
887874
find,
888875
setIndex: (index) => {
@@ -891,7 +878,6 @@ function initRedundancy(cfg) {
891878
getIndex: () => config.index,
892879
cleanup
893880
};
894-
return instance;
895881
}
896882

897883
function emptyCallback$1() {}
@@ -903,12 +889,10 @@ function getRedundancyCache(provider) {
903889
if (!redundancyCache[provider]) {
904890
const config = getAPIConfig(provider);
905891
if (!config) return;
906-
const redundancy = initRedundancy(config);
907-
const cachedReundancy = {
892+
redundancyCache[provider] = {
908893
config,
909-
redundancy
894+
redundancy: initRedundancy(config)
910895
};
911-
redundancyCache[provider] = cachedReundancy;
912896
}
913897
return redundancyCache[provider];
914898
}
@@ -931,8 +915,7 @@ function sendAPIQuery(target, query, callback) {
931915
const config = createAPIConfig(target);
932916
if (config) {
933917
redundancy = initRedundancy(config);
934-
const moduleKey = target.resources ? target.resources[0] : "";
935-
const api = getAPIModule(moduleKey);
918+
const api = getAPIModule(target.resources ? target.resources[0] : "");
936919
if (api) send = api.send;
937920
}
938921
}
@@ -982,8 +965,7 @@ function parseLoaderResponse(storage, icons, data) {
982965
});
983966
}
984967
if (data && typeof data === "object") try {
985-
const parsed = addIconSet(storage, data);
986-
if (!parsed.length) {
968+
if (!addIconSet(storage, data).length) {
987969
checkMissing();
988970
return;
989971
}
@@ -1027,13 +1009,11 @@ function loadNewIcons(storage, icons) {
10271009
}
10281010
if (customIconLoader) {
10291011
icons$1.forEach((name) => {
1030-
const response = customIconLoader(name, prefix, provider);
1031-
parsePossiblyAsyncResponse(response, (data) => {
1032-
const iconSet = data ? {
1012+
parsePossiblyAsyncResponse(customIconLoader(name, prefix, provider), (data) => {
1013+
parseLoaderResponse(storage, [name], data ? {
10331014
prefix,
10341015
icons: { [name]: data }
1035-
} : null;
1036-
parseLoaderResponse(storage, [name], iconSet);
1016+
} : null);
10371017
});
10381018
});
10391019
return;
@@ -1046,8 +1026,7 @@ function loadNewIcons(storage, icons) {
10461026
parseLoaderResponse(storage, valid, null);
10471027
return;
10481028
}
1049-
const params = api.prepare(provider, prefix, valid);
1050-
params.forEach((item) => {
1029+
api.prepare(provider, prefix, valid).forEach((item) => {
10511030
sendAPIQuery(provider, item, (data) => {
10521031
parseLoaderResponse(storage, item.icons, data);
10531032
});
@@ -1059,8 +1038,7 @@ function loadNewIcons(storage, icons) {
10591038
* Load icons
10601039
*/
10611040
const loadIcons$1 = (icons, callback) => {
1062-
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1063-
const sortedIcons = sortIcons(cleanedIcons);
1041+
const sortedIcons = sortIcons(listToIcons(icons, true, allowSimpleNames()));
10641042
if (!sortedIcons.pending.length) {
10651043
let callCallback = true;
10661044
if (callback) setTimeout(() => {
@@ -1524,8 +1502,7 @@ const send = (host, params, callback) => {
15241502
switch (params.type) {
15251503
case "icons": {
15261504
const prefix = params.prefix;
1527-
const icons = params.icons;
1528-
const iconsList = icons.join(",");
1505+
const iconsList = params.icons.join(",");
15291506
const urlParams = new URLSearchParams({ icons: iconsList });
15301507
path += prefix + ".json?" + urlParams.toString();
15311508
break;

iconify-icon/3-latest/iconify-icon.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export declare type IconifyAPISendQuery = (host: string, params: IconifyAPIQuery
139139
* Interface for exported builder functions
140140
*/
141141
export declare interface IconifyBuilderFunctions {
142-
replaceIDs?: (body: string, prefix?: string | (() => string)) => string;
142+
replaceIDs?: (body: string) => string;
143+
clearIDCache?: () => void;
143144
calculateSize: (size: string | number, ratio: number, precision?: number) => string | number;
144145
buildIcon: (icon: IconifyIcon, customisations?: IconifyIconCustomisations) => IconifyIconBuildResult;
145146
}

iconify-icon/3-latest/iconify-icon.js

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,30 @@
77
* Licensed under MIT.
88
*
99
* @license MIT
10-
* @version 3.0.1
10+
* @version 3.0.2
1111
*/
1212
(function () {
1313
'use strict';
1414

15-
/**
16-
* Default values for dimensions
17-
*/
15+
/** Default values for dimensions */
1816
const defaultIconDimensions = Object.freeze({
1917
left: 0,
2018
top: 0,
2119
width: 16,
2220
height: 16
2321
});
24-
/**
25-
* Default values for transformations
26-
*/
22+
/** Default values for transformations */
2723
const defaultIconTransformations = Object.freeze({
2824
rotate: 0,
2925
vFlip: false,
3026
hFlip: false
3127
});
32-
/**
33-
* Default values for all optional IconifyIcon properties
34-
*/
28+
/** Default values for all optional IconifyIcon properties */
3529
const defaultIconProps = Object.freeze({
3630
...defaultIconDimensions,
3731
...defaultIconTransformations
3832
});
39-
/**
40-
* Default values for all properties used in ExtendedIconifyIcon
41-
*/
33+
/** Default values for all properties used in ExtendedIconifyIcon */
4234
const defaultExtendedIconProps = Object.freeze({
4335
...defaultIconProps,
4436
body: "",
@@ -93,8 +85,7 @@
9385
*/
9486
function flipFromString(custom, flip) {
9587
flip.split(separator).forEach((str) => {
96-
const value = str.trim();
97-
switch (value) {
88+
switch (str.trim()) {
9889
case "horizontal":
9990
custom.hFlip = true;
10091
break;
@@ -376,10 +367,8 @@
376367
*/
377368
function listIcons(provider, prefix) {
378369
let allIcons = [];
379-
const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
380-
providers.forEach((provider$1) => {
381-
const prefixes = typeof provider$1 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider$1] || {});
382-
prefixes.forEach((prefix$1) => {
370+
(typeof provider === "string" ? [provider] : Object.keys(dataStorage)).forEach((provider$1) => {
371+
(typeof provider$1 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider$1] || {})).forEach((prefix$1) => {
383372
const storage = getStorage(provider$1, prefix$1);
384373
allIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider$1 !== "" ? "@" + provider$1 + ":" : "") + prefix$1 + ":" + name));
385374
});
@@ -445,8 +434,7 @@
445434
prefix,
446435
name: "a"
447436
})) return false;
448-
const storage = getStorage(provider, prefix);
449-
return !!addIconSet(storage, data);
437+
return !!addIconSet(getStorage(provider, prefix), data);
450438
}
451439
/**
452440
* Check if icon data is available
@@ -621,7 +609,7 @@
621609
resources = source.resources;
622610
if (!(resources instanceof Array) || !resources.length) return null;
623611
}
624-
const result = {
612+
return {
625613
resources,
626614
path: source.path || "/",
627615
maxURL: source.maxURL || 500,
@@ -631,7 +619,6 @@
631619
index: source.index || 0,
632620
dataAfterTimeout: source.dataAfterTimeout !== false
633621
};
634-
return result;
635622
}
636623
/**
637624
* Local storage
@@ -883,7 +870,7 @@
883870
return callback(value);
884871
}) || null;
885872
}
886-
const instance = {
873+
return {
887874
query,
888875
find,
889876
setIndex: (index) => {
@@ -892,7 +879,6 @@
892879
getIndex: () => config.index,
893880
cleanup
894881
};
895-
return instance;
896882
}
897883

898884
function emptyCallback$1() {}
@@ -904,12 +890,10 @@
904890
if (!redundancyCache[provider]) {
905891
const config = getAPIConfig(provider);
906892
if (!config) return;
907-
const redundancy = initRedundancy(config);
908-
const cachedReundancy = {
893+
redundancyCache[provider] = {
909894
config,
910-
redundancy
895+
redundancy: initRedundancy(config)
911896
};
912-
redundancyCache[provider] = cachedReundancy;
913897
}
914898
return redundancyCache[provider];
915899
}
@@ -932,8 +916,7 @@
932916
const config = createAPIConfig(target);
933917
if (config) {
934918
redundancy = initRedundancy(config);
935-
const moduleKey = target.resources ? target.resources[0] : "";
936-
const api = getAPIModule(moduleKey);
919+
const api = getAPIModule(target.resources ? target.resources[0] : "");
937920
if (api) send = api.send;
938921
}
939922
}
@@ -983,8 +966,7 @@
983966
});
984967
}
985968
if (data && typeof data === "object") try {
986-
const parsed = addIconSet(storage, data);
987-
if (!parsed.length) {
969+
if (!addIconSet(storage, data).length) {
988970
checkMissing();
989971
return;
990972
}
@@ -1028,13 +1010,11 @@
10281010
}
10291011
if (customIconLoader) {
10301012
icons$1.forEach((name) => {
1031-
const response = customIconLoader(name, prefix, provider);
1032-
parsePossiblyAsyncResponse(response, (data) => {
1033-
const iconSet = data ? {
1013+
parsePossiblyAsyncResponse(customIconLoader(name, prefix, provider), (data) => {
1014+
parseLoaderResponse(storage, [name], data ? {
10341015
prefix,
10351016
icons: { [name]: data }
1036-
} : null;
1037-
parseLoaderResponse(storage, [name], iconSet);
1017+
} : null);
10381018
});
10391019
});
10401020
return;
@@ -1047,8 +1027,7 @@
10471027
parseLoaderResponse(storage, valid, null);
10481028
return;
10491029
}
1050-
const params = api.prepare(provider, prefix, valid);
1051-
params.forEach((item) => {
1030+
api.prepare(provider, prefix, valid).forEach((item) => {
10521031
sendAPIQuery(provider, item, (data) => {
10531032
parseLoaderResponse(storage, item.icons, data);
10541033
});
@@ -1060,8 +1039,7 @@
10601039
* Load icons
10611040
*/
10621041
const loadIcons = (icons, callback) => {
1063-
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1064-
const sortedIcons = sortIcons(cleanedIcons);
1042+
const sortedIcons = sortIcons(listToIcons(icons, true, allowSimpleNames()));
10651043
if (!sortedIcons.pending.length) {
10661044
let callCallback = true;
10671045
if (callback) setTimeout(() => {
@@ -1525,8 +1503,7 @@
15251503
switch (params.type) {
15261504
case "icons": {
15271505
const prefix = params.prefix;
1528-
const icons = params.icons;
1529-
const iconsList = icons.join(",");
1506+
const iconsList = params.icons.join(",");
15301507
const urlParams = new URLSearchParams({ icons: iconsList });
15311508
path += prefix + ".json?" + urlParams.toString();
15321509
break;

0 commit comments

Comments
 (0)