viconic-react-icons 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2052,20 +2052,36 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2052
2052
  if (!bj || !bj.icons) return;
2053
2053
  const W = window.__viconic = window.__viconic || {};
2054
2054
  W.icons = W.icons || {};
2055
+ const cdnFetches = [];
2055
2056
  for (const n in bj.icons) {
2056
2057
  if (!Object.prototype.hasOwnProperty.call(bj.icons, n)) continue;
2057
2058
  const d = bj.icons[n];
2058
2059
  const svg = d.svg || "";
2059
- if (!svg || !svg.includes("<")) continue;
2060
- W.icons[`@${prefix}/${n}`] = svg;
2061
- W.icons[`${prefix}:${n}`] = svg;
2062
- W.icons[`${prefix}/${n}`] = svg;
2063
- W.icons[n] = W.icons[n] || svg;
2064
- }
2065
- try {
2066
- document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2067
- } catch (e) {
2060
+ if (svg && svg.includes("<")) {
2061
+ W.icons[`@${prefix}/${n}`] = svg;
2062
+ W.icons[`${prefix}:${n}`] = svg;
2063
+ W.icons[`${prefix}/${n}`] = svg;
2064
+ W.icons[n] = W.icons[n] || svg;
2065
+ } else if (d.cdn_url) {
2066
+ cdnFetches.push(
2067
+ fetch(d.cdn_url).then((r) => r.ok ? r.text() : "").then((s) => {
2068
+ if (s && s.includes("<")) {
2069
+ W.icons[`@${prefix}/${n}`] = s;
2070
+ W.icons[`${prefix}:${n}`] = s;
2071
+ W.icons[`${prefix}/${n}`] = s;
2072
+ W.icons[n] = W.icons[n] || s;
2073
+ }
2074
+ }).catch(() => {
2075
+ })
2076
+ );
2077
+ }
2068
2078
  }
2079
+ Promise.all(cdnFetches).then(() => {
2080
+ try {
2081
+ document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2082
+ } catch (e) {
2083
+ }
2084
+ });
2069
2085
  }).catch(() => {
2070
2086
  });
2071
2087
  }, 150);
@@ -2150,7 +2166,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2150
2166
  window.CopyIcons.forceProcess(el);
2151
2167
  }
2152
2168
  }
2153
- if (!isInjected() && el._u) {
2169
+ if (!isInjected() && !isKitIcon && el._u) {
2154
2170
  el._u();
2155
2171
  }
2156
2172
  if (isInjected()) return;
@@ -2166,7 +2182,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2166
2182
  return;
2167
2183
  }
2168
2184
  }
2169
- if (el._u) el._u();
2185
+ if (!isKitIcon && el._u) el._u();
2170
2186
  if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
2171
2187
  window.CopyIcons.forceProcess(el);
2172
2188
  }
package/dist/index.mjs CHANGED
@@ -2017,20 +2017,36 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2017
2017
  if (!bj || !bj.icons) return;
2018
2018
  const W = window.__viconic = window.__viconic || {};
2019
2019
  W.icons = W.icons || {};
2020
+ const cdnFetches = [];
2020
2021
  for (const n in bj.icons) {
2021
2022
  if (!Object.prototype.hasOwnProperty.call(bj.icons, n)) continue;
2022
2023
  const d = bj.icons[n];
2023
2024
  const svg = d.svg || "";
2024
- if (!svg || !svg.includes("<")) continue;
2025
- W.icons[`@${prefix}/${n}`] = svg;
2026
- W.icons[`${prefix}:${n}`] = svg;
2027
- W.icons[`${prefix}/${n}`] = svg;
2028
- W.icons[n] = W.icons[n] || svg;
2029
- }
2030
- try {
2031
- document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2032
- } catch (e) {
2025
+ if (svg && svg.includes("<")) {
2026
+ W.icons[`@${prefix}/${n}`] = svg;
2027
+ W.icons[`${prefix}:${n}`] = svg;
2028
+ W.icons[`${prefix}/${n}`] = svg;
2029
+ W.icons[n] = W.icons[n] || svg;
2030
+ } else if (d.cdn_url) {
2031
+ cdnFetches.push(
2032
+ fetch(d.cdn_url).then((r) => r.ok ? r.text() : "").then((s) => {
2033
+ if (s && s.includes("<")) {
2034
+ W.icons[`@${prefix}/${n}`] = s;
2035
+ W.icons[`${prefix}:${n}`] = s;
2036
+ W.icons[`${prefix}/${n}`] = s;
2037
+ W.icons[n] = W.icons[n] || s;
2038
+ }
2039
+ }).catch(() => {
2040
+ })
2041
+ );
2042
+ }
2033
2043
  }
2044
+ Promise.all(cdnFetches).then(() => {
2045
+ try {
2046
+ document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2047
+ } catch (e) {
2048
+ }
2049
+ });
2034
2050
  }).catch(() => {
2035
2051
  });
2036
2052
  }, 150);
@@ -2115,7 +2131,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2115
2131
  window.CopyIcons.forceProcess(el);
2116
2132
  }
2117
2133
  }
2118
- if (!isInjected() && el._u) {
2134
+ if (!isInjected() && !isKitIcon && el._u) {
2119
2135
  el._u();
2120
2136
  }
2121
2137
  if (isInjected()) return;
@@ -2131,7 +2147,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2131
2147
  return;
2132
2148
  }
2133
2149
  }
2134
- if (el._u) el._u();
2150
+ if (!isKitIcon && el._u) el._u();
2135
2151
  if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
2136
2152
  window.CopyIcons.forceProcess(el);
2137
2153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viconic-react-icons",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "Viconic Smart Icons loader for React — supports Kit and 200k+ system icons",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/index.jsx CHANGED
@@ -109,17 +109,37 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
109
109
  if (!bj || !bj.icons) return;
110
110
  const W = (window.__viconic = window.__viconic || {});
111
111
  W.icons = W.icons || {};
112
+ const cdnFetches = [];
112
113
  for (const n in bj.icons) {
113
114
  if (!Object.prototype.hasOwnProperty.call(bj.icons, n)) continue;
114
115
  const d = bj.icons[n];
115
116
  const svg = d.svg || '';
116
- if (!svg || !svg.includes('<')) continue;
117
- W.icons[`@${prefix}/${n}`] = svg;
118
- W.icons[`${prefix}:${n}`] = svg;
119
- W.icons[`${prefix}/${n}`] = svg;
120
- W.icons[n] = W.icons[n] || svg;
117
+ if (svg && svg.includes('<')) {
118
+ W.icons[`@${prefix}/${n}`] = svg;
119
+ W.icons[`${prefix}:${n}`] = svg;
120
+ W.icons[`${prefix}/${n}`] = svg;
121
+ W.icons[n] = W.icons[n] || svg;
122
+ } else if (d.cdn_url) {
123
+ // User-uploaded icon: fetch SVG from CDN and store in W.icons
124
+ // so loader refresh() finds it and doesn't fetch individually
125
+ cdnFetches.push(
126
+ fetch(d.cdn_url)
127
+ .then(r => r.ok ? r.text() : '')
128
+ .then(s => {
129
+ if (s && s.includes('<')) {
130
+ W.icons[`@${prefix}/${n}`] = s;
131
+ W.icons[`${prefix}:${n}`] = s;
132
+ W.icons[`${prefix}/${n}`] = s;
133
+ W.icons[n] = W.icons[n] || s;
134
+ }
135
+ })
136
+ .catch(() => {})
137
+ );
138
+ }
121
139
  }
122
- try { document.dispatchEvent(new CustomEvent('viconic:ready', { detail: { prefix, kitId } })); } catch(e) {}
140
+ Promise.all(cdnFetches).then(() => {
141
+ try { document.dispatchEvent(new CustomEvent('viconic:ready', { detail: { prefix, kitId } })); } catch(e) {}
142
+ });
123
143
  })
124
144
  .catch(() => {});
125
145
  }, 150);
@@ -263,8 +283,8 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
263
283
  }
264
284
  }
265
285
 
266
- // --- PATH 3: Custom element _u() call (kit loader registered element) ---
267
- if (!isInjected() && el._u) {
286
+ // --- PATH 3: Custom element _u() call (kit loader registered element, system icons only) ---
287
+ if (!isInjected() && !isKitIcon && el._u) {
268
288
  el._u();
269
289
  }
270
290
 
@@ -286,7 +306,7 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
286
306
  return;
287
307
  }
288
308
  }
289
- if (el._u) el._u();
309
+ if (!isKitIcon && el._u) el._u();
290
310
  if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
291
311
  window.CopyIcons.forceProcess(el);
292
312
  }